* [PATCH] iommu/amd: Explicitly bail from enable_iommus_vapic() when in legacy mode
@ 2025-03-15 3:09 Sean Christopherson
2026-04-06 23:05 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2025-03-15 3:09 UTC (permalink / raw)
To: Joerg Roedel
Cc: iommu, linux-kernel, Suravee Suthikulpanit, Sean Christopherson
Bail early from enable_iommus_vapic() if IOMMUs are configured for either
of the legacy modes, as it's absurdly difficult to see that
iommu_ga_log_enable() is guaranteed to fail because iommu_init_ga_log()
skips allocating the ga_log.
Opportunistically have iommu_ga_log_enable() WARN if it's called without
IOMMUs being configured to support AVIC/vAPIC.
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
drivers/iommu/amd/init.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index cb536d372b12..05c568da589a 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -931,8 +931,8 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
static int iommu_init_ga_log(struct amd_iommu *iommu)
{
- if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
- return 0;
+ if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
+ return -EINVAL;
iommu->ga_log = iommu_alloc_pages(GFP_KERNEL, get_order(GA_LOG_SIZE));
if (!iommu->ga_log)
@@ -2863,8 +2863,10 @@ static void enable_iommus_vapic(void)
return;
}
- if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
- !check_feature(FEATURE_GAM_VAPIC)) {
+ if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
+ return;
+
+ if (!check_feature(FEATURE_GAM_VAPIC)) {
amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
return;
}
base-commit: ea9bd29a9c0d757b3384ae3e633e6bbaddf00725
--
2.49.0.rc1.451.g8f38331e32-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iommu/amd: Explicitly bail from enable_iommus_vapic() when in legacy mode
2025-03-15 3:09 [PATCH] iommu/amd: Explicitly bail from enable_iommus_vapic() when in legacy mode Sean Christopherson
@ 2026-04-06 23:05 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2026-04-06 23:05 UTC (permalink / raw)
To: Joerg Roedel, iommu, linux-kernel, Suravee Suthikulpanit
On Fri, Mar 14, 2025, Sean Christopherson wrote:
> Bail early from enable_iommus_vapic() if IOMMUs are configured for either
> of the legacy modes, as it's absurdly difficult to see that
> iommu_ga_log_enable() is guaranteed to fail because iommu_init_ga_log()
> skips allocating the ga_log.
>
> Opportunistically have iommu_ga_log_enable() WARN if it's called without
> IOMMUs being configured to support AVIC/vAPIC.
>
> Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> drivers/iommu/amd/init.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
> index cb536d372b12..05c568da589a 100644
> --- a/drivers/iommu/amd/init.c
> +++ b/drivers/iommu/amd/init.c
> @@ -931,8 +931,8 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
>
> static int iommu_init_ga_log(struct amd_iommu *iommu)
> {
> - if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
> - return 0;
> + if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
> + return -EINVAL;
>
> iommu->ga_log = iommu_alloc_pages(GFP_KERNEL, get_order(GA_LOG_SIZE));
> if (!iommu->ga_log)
> @@ -2863,8 +2863,10 @@ static void enable_iommus_vapic(void)
> return;
> }
>
> - if (AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir) &&
> - !check_feature(FEATURE_GAM_VAPIC)) {
> + if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
> + return;
> +
> + if (!check_feature(FEATURE_GAM_VAPIC)) {
> amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY_GA;
> return;
> }
>
> base-commit: ea9bd29a9c0d757b3384ae3e633e6bbaddf00725
> --
Another ping. This too still applies.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-06 23:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15 3:09 [PATCH] iommu/amd: Explicitly bail from enable_iommus_vapic() when in legacy mode Sean Christopherson
2026-04-06 23:05 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox