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

[PATCH] x86: fix build with old gcc after CPU policy changes


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 18 Apr 2023 12:15:28 +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=nseY0nHkP0nk+3AOLLKCsOSnbTCI3BP0bHCtUpZGXgU=; b=IO1pwRfj2lsK+4OgYJGB4RHfdZVZaf7tlggqw/W6kN35hlGEtcRI7ceiDztyRTBKlvmSbfs2vfiutbO09hl2tLj2GAfGPwhzvM8rkaPYqLLVemYxNucBPNGOBE4t6HHJKUXaJ8YhgtcG0NRftf6RwyXt/PH4HeH8rKIdWeNreQQNgsQlEbTupbgy7rzAXvdJE7uwNjw4xBsm4LFUF9gcDiPTcFuuPz4x1tQlmCDKLvYeByD6TzNVBs4Upr475aM2+VMJTlH56rnZZTeqgrINjVE6z6R6FvXwLZlBwOZXFPqwZn49OPXbV4ni+4ESJW/yJ/IaZHGZaFuxguRD7CgDqg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UCUfz0ppoYsFFv9sJMAIHYYae8HdhN1YZwWOIqgZmrgYfii6xSJPTx9Y2jVM9dX0YW8IBXix2NtYLNMfh/K4ctyALBrUjI81DuJA3Hn8kPNG+MqkIt+X8V475IXMKbePAd17LMEbH0uK+sVzp94OiM/VhTtiM+JgLehjPKueTk6z/xISD4EsSglMBbV8MJHQpQQCvpGPWwO+8sqH56R8PYaGoOl/TaapTox2fj4waRaRZxt8xr3T2o3NhCYpxeTE4tGg4zmnEPCG5nWIBrLMUmDk7J21YqyPWJnQTjh2hxN7zrCXzdyJZBjkFoLd6tZhNSYP52VNOs7eHt1UPV/H2Q==
  • 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>
  • Delivery-date: Tue, 18 Apr 2023 10:16:16 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Old gcc won't cope with initializers involving unnamed struct/union
fields.

Fixes: 441b1b2a50ea ("x86/emul: Switch x86_emulate_ctxt to cpu_policy")
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

--- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
@@ -893,12 +893,14 @@ int LLVMFuzzerTestOneInput(const uint8_t
     struct x86_emulate_ctxt ctxt = {
         .data = &state,
         .regs = &input.regs,
-        .cpu_policy = &cp,
         .addr_size = 8 * sizeof(void *),
         .sp_size = 8 * sizeof(void *),
     };
     int rc;
 
+    /* Not part of the initializer, for old gcc to cope. */
+    ctxt.cpu_policy = &cp;
+
     /* Reset all global state variables */
     memset(&input, 0, sizeof(input));
 
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -1313,12 +1313,14 @@ int pv_emulate_privileged_op(struct cpu_
     struct domain *currd = curr->domain;
     struct priv_op_ctxt ctxt = {
         .ctxt.regs = regs,
-        .ctxt.cpu_policy = currd->arch.cpu_policy,
         .ctxt.lma = !is_pv_32bit_domain(currd),
     };
     int rc;
     unsigned int eflags, ar;
 
+    /* Not part of the initializer, for old gcc to cope. */
+    ctxt.ctxt.cpu_policy = currd->arch.cpu_policy;
+
     if ( !pv_emul_read_descriptor(regs->cs, curr, &ctxt.cs.base,
                                   &ctxt.cs.limit, &ar, 1) ||
          !(ar & _SEGMENT_S) ||
--- a/xen/arch/x86/pv/ro-page-fault.c
+++ b/xen/arch/x86/pv/ro-page-fault.c
@@ -344,7 +344,6 @@ int pv_ro_page_fault(unsigned long addr,
     unsigned int addr_size = is_pv_32bit_domain(currd) ? 32 : BITS_PER_LONG;
     struct x86_emulate_ctxt ctxt = {
         .regs      = regs,
-        .cpu_policy = currd->arch.cpu_policy,
         .addr_size = addr_size,
         .sp_size   = addr_size,
         .lma       = addr_size > 32,
@@ -352,6 +351,9 @@ int pv_ro_page_fault(unsigned long addr,
     int rc;
     bool mmio_ro;
 
+    /* Not part of the initializer, for old gcc to cope. */
+    ctxt.cpu_policy = currd->arch.cpu_policy;
+
     /* Attempt to read the PTE that maps the VA being accessed. */
     pte = guest_get_eff_kern_l1e(addr);
 



 


Rackspace

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