From: "Mario Limonciello (AMD)" <[email protected]> [ Upstream commit 7bbf6d15e935abbb3d604c1fa157350e84a26f98 ]
SVA support is required, which isn't configured by hypervisor solutions. Closes: https://github.com/QubesOS/qubes-issues/issues/10275 Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/4656 Reviewed-by: Lizhi Hou <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mario Limonciello (AMD) <[email protected]> Signed-off-by: Sasha Levin <[email protected]> --- LLM Generated explanations, may be completely bogus: ## Commit Analysis: accel/amdxdna: Block running under a hypervisor ### 1. COMMIT MESSAGE ANALYSIS The commit message indicates this fix prevents the amdxdna driver from running under hypervisors because SVA (Shared Virtual Addressing) support is required but not configured in hypervisor solutions. Two bug tracker links are provided: - QubesOS issue #10275 - freedesktop.org AMD issue #4656 This shows real users are hitting this problem. ### 2. CODE CHANGE ANALYSIS The change is minimal: ```c +#include <asm/hypervisor.h> ... + if (!hypervisor_is_type(X86_HYPER_NATIVE)) { + XDNA_ERR(xdna, "Running under hypervisor not supported"); + return -EINVAL; + } ``` The fix adds an early check in `aie2_init()` that: 1. Uses the well-established x86 hypervisor detection infrastructure 2. If not running on bare metal (native), prints an error and returns -EINVAL 3. This happens before any resource allocation, making it a clean early- exit **The bug mechanism:** Without this check, when users run this driver in virtualized environments (QubesOS, etc.), the driver attempts to initialize but fails due to missing SVA support. This leads to confusing errors, potential crashes, or undefined behavior. The fix makes the driver fail gracefully with a clear message. ### 3. CLASSIFICATION This is a **bug fix** - specifically a "graceful failure" fix that prevents the driver from attempting an unsupported configuration. It does not add features; it blocks an unsupported environment with a clear error. ### 4. SCOPE AND RISK ASSESSMENT - **Lines changed:** 5 lines (1 include + 4 lines of logic) - **Files touched:** 1 file - **Complexity:** Very low - trivial conditional check - **Risk:** Very low - early return before any resource allocation - **Dependencies:** Uses `hypervisor_is_type()` and `X86_HYPER_NATIVE` which have been in the kernel for years (x86 hypervisor detection is mature infrastructure) ### 5. USER IMPACT - **Affected users:** Those running VMs (QubesOS, etc.) with AMD XDNA hardware - **Severity without fix:** Confusing failures, crashes, or undefined behavior when attempting to use the driver - **Severity with fix:** Clean error message explaining the limitation The linked issues show this is a real problem users are encountering. ### 6. STABILITY INDICATORS - Has `Reviewed-by:` from AMD engineer (Lizhi Hou) - Has real bug reports from multiple sources - Simple, obvious fix ### 7. DEPENDENCY CHECK The amdxdna driver is relatively new (added around kernel 6.11-6.12). It exists in: - Recent mainline releases - Potentially only very recent stable trees (6.12.x if supported) The hypervisor detection APIs used (`hypervisor_is_type`, `X86_HYPER_NATIVE`) are stable and have existed for years. ### 8. STABLE CRITERIA ASSESSMENT | Criterion | Assessment | |-----------|------------| | Obviously correct | ✅ Yes - trivial check | | Fixes real bug | ✅ Yes - prevents crashes in VMs | | Important issue | ✅ Yes - affects VM users | | Small/contained | ✅ Yes - 5 lines | | No new features | ✅ Yes - disables unsupported config | | Low risk | ✅ Yes - clean early return | ### CONCLUSION This commit is appropriate for stable backporting. It's a small, low- risk fix that prevents the driver from running in unsupported virtualized environments where it would otherwise fail with confusing behavior or crashes. The fix is surgically precise - adding an early check with a clean error return. The stable maintainers will only apply this to kernel versions that contain the amdxdna driver (likely only very recent stable trees like 6.12.x). The patch itself meets all stable criteria: obviously correct, fixes a real bug that users are hitting, small scope, and no new features. **YES** drivers/accel/amdxdna/aie2_pci.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c index 43f725e1a2d7..6e07793bbeac 100644 --- a/drivers/accel/amdxdna/aie2_pci.c +++ b/drivers/accel/amdxdna/aie2_pci.c @@ -17,6 +17,7 @@ #include <linux/iopoll.h> #include <linux/pci.h> #include <linux/xarray.h> +#include <asm/hypervisor.h> #include "aie2_msg_priv.h" #include "aie2_pci.h" @@ -486,6 +487,11 @@ static int aie2_init(struct amdxdna_dev *xdna) unsigned long bars = 0; int i, nvec, ret; + if (!hypervisor_is_type(X86_HYPER_NATIVE)) { + XDNA_ERR(xdna, "Running under hypervisor not supported"); + return -EINVAL; + } + ndev = drmm_kzalloc(&xdna->ddev, sizeof(*ndev), GFP_KERNEL); if (!ndev) return -ENOMEM; -- 2.51.0
