[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/3] x86/APIC: avoid iommu_supports_x2apic() on error path


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 21 Oct 2021 11:58:37 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XttmN+xWknonju2h1s9l5A0Df7pJEnl/TZUURByJQLA=; b=MtlICZTW0X7RUmlsDDoPxdqYuDMHpIgvBeEaQiJQxN+3OgEd/8lz6k9wAJl3e5cQjQPFQ73S6bmD523t4yw4iFJB87W0vJiRBKaAOn8WykAijmdEBvTJHS9TnmFevOPzSICYfaYCc0ycHMkthWVVkc25nRaRLR+5TGPWYx/Jn4KyQPBf0h231IQDO92VAhGUqzYfsCClXUR3XL+kJGsXuJRMQGT2fIqejjpTQ0jZcE15/zqCBg67mATdUWcIhUMXv9COKve9+2nDFnjVnqOY3d9/Y/XidGqu8q420cQa5c3AsRbgYPeDOygv3jGs/m2i9GWc13SE66SfV7/cwU5xLw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G5sDVc/gRHT0W+VbZSgFYnJgnt3F90Jo8ksNFR+qzk8wb9TXAkNEHnhigyiX63Yb2d2pJUkkmk3Cu6U7UkCpppExY2UJy4aDkDDM7aK6ePkXTZyfiJSjbxxPBm4yM0s/aYegNANwa7PUNld30tafedR7Y7OywGhGmFgJgb7fODIAPsWcBm49/x5xnNZ/xVSkg0iFDZzyK+D82Gx2sSyHlMxxBQYJdzN6jVimS4tkIvRJzOLOCfpA+rS8BvPiFg2uJB1fIPFwzOrmPAztb2GxgMphds0VFxZc/l4SIfCgEK8/IONVKJQCnK5qL6AVtVfenJtZr0IKl2OiPukBRXi8YQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Thu, 21 Oct 2021 09:58:45 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The value it returns may change from true to false in case
iommu_enable_x2apic() fails and, as a side effect, clears iommu_intremap
(as can happen at least on AMD). Latch the return value from the first
invocation to replace the second one.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: New.

--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -865,6 +865,7 @@ void x2apic_ap_setup(void)
 void __init x2apic_bsp_setup(void)
 {
     struct IO_APIC_route_entry **ioapic_entries = NULL;
+    bool iommu_x2apic;
     const char *orig_name;
 
     if ( !cpu_has_x2apic )
@@ -880,7 +881,8 @@ void __init x2apic_bsp_setup(void)
         printk("x2APIC: Already enabled by BIOS: Ignoring cmdline disable.\n");
     }
 
-    if ( iommu_supports_x2apic() )
+    iommu_x2apic = iommu_supports_x2apic();
+    if ( iommu_x2apic )
     {
         if ( (ioapic_entries = alloc_ioapic_entries()) == NULL )
         {
@@ -933,8 +935,11 @@ void __init x2apic_bsp_setup(void)
         printk("Switched to APIC driver %s\n", genapic.name);
 
 restore_out:
-    /* iommu_x2apic_enabled cannot be used here in the error case. */
-    if ( iommu_supports_x2apic() )
+    /*
+     * iommu_x2apic_enabled and iommu_supports_x2apic() cannot be used here
+     * in the error case.
+     */
+    if ( iommu_x2apic )
     {
         /*
          * NB: do not use raw mode when restoring entries if the iommu has




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.