Archive-only list for patches
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: "Mario Limonciello (AMD)" <superm1@kernel.org>,
	Lizhi Hou <lizhi.hou@amd.com>, Sasha Levin <sashal@kernel.org>,
	mamin506@gmail.com, dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 6.18] accel/amdxdna: Block running under a hypervisor
Date: Tue, 23 Dec 2025 05:05:13 -0500	[thread overview]
Message-ID: <20251223100518.2383364-9-sashal@kernel.org> (raw)
In-Reply-To: <20251223100518.2383364-1-sashal@kernel.org>

From: "Mario Limonciello (AMD)" <superm1@kernel.org>

[ 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 <lizhi.hou@amd.com>
Link: https://patch.msgid.link/20251213054513.87925-1-superm1@kernel.org
Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

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


  parent reply	other threads:[~2025-12-23 10:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 10:05 [PATCH AUTOSEL 6.18-5.10] powercap: fix sscanf() error return value handling Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.6] netfilter: nf_tables: avoid chain re-validation if possible Sasha Levin
2025-12-23 10:12   ` Florian Westphal
2026-01-14 20:00     ` Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.12] spi: mt65xx: Use IRQF_ONESHOT with threaded IRQ Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-5.10] can: j1939: make j1939_session_activate() fail if device is no longer registered Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-5.10] powercap: fix race condition in register_control_type() Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18] block: validate pi_offset integrity limit Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.6] drm/amd/display: Fix DP no audio issue Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.12] ata: libata-core: Disable LPM on ST2000DM008-2FR102 Sasha Levin
2025-12-23 10:05 ` Sasha Levin [this message]
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.12] drm/amdkfd: Fix improper NULL termination of queue restore SMI event string Sasha Levin
2025-12-23 10:05 ` [PATCH AUTOSEL 6.18-6.12] net: sfp: extend Potron XGSPON quirk to cover additional EEPROM variant Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251223100518.2383364-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lizhi.hou@amd.com \
    --cc=mamin506@gmail.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=superm1@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox