From patchwork Fri Jun 7 12:07:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 10981583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8599F14B6 for ; Fri, 7 Jun 2019 12:08:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7509D2842B for ; Fri, 7 Jun 2019 12:08:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68CDB284C9; Fri, 7 Jun 2019 12:08:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DF2522842B for ; Fri, 7 Jun 2019 12:08:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hZDeR-0000NB-3B; Fri, 07 Jun 2019 12:07:19 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hZDeQ-0000N6-7a for xen-devel@lists.xenproject.org; Fri, 07 Jun 2019 12:07:18 +0000 X-Inumbo-ID: c85c3eca-891c-11e9-82fa-631995befb48 Received: from esa3.hc3370-68.iphmx.com (unknown [216.71.145.155]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c85c3eca-891c-11e9-82fa-631995befb48; Fri, 07 Jun 2019 12:07:13 +0000 (UTC) Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=SoftFail smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: SoftFail (esa3.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com is inclined to not designate 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 include:spf.citrix.com include:spf2.citrix.com include:ironport.citrix.com exists:%{i}._spf.mta.salesforce.com ~all" Received-SPF: None (esa3.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa3.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 17GX6J6aerUjZYKTXFETGqo/kyFwrYHdHTCmgnXAthn2hPzQethfsNOhdCr+1nVpo9FFlje2f6 MF1tJ9szE+eDKmxTPTpvj5c7lNuYoToqJiPMkOSPaK11vDVSKivoIS3oa/pxHM90GbkXzJvgM+ hSaU0uvCYkhz9AwFZT5WKO9FkrJsnJEHQOK2/wgpTyKJnqB+o7ubalXecwXr9S9nNjSGbf3WsU vU5vu4NqqpvYgtjxnnsDqcM2jchbxxzxt+24mc4xHh/zy5pl1h1CYITJ0vyfc+/Czz3dXUq403 /Bo= X-SBRS: -0.9 X-MesageID: 1451988 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.63,563,1557201600"; d="scan'208";a="1451988" From: Andrew Cooper To: Xen-devel Date: Fri, 7 Jun 2019 13:07:04 +0100 Message-ID: <1559909224-26062-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] x86: Fix boot with CONFIG_XSM enabled following c/s 7177f589ba X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, booting staging fails with: (XEN) Using APIC driver default (XEN) ----[ Xen-4.13-unstable x86_64 debug=y Not tainted ]---- (XEN) CPU: 0 (XEN) RIP: e008:[] __x86_indirect_thunk_rax+0xe/0x10 (XEN) RFLAGS: 0000000000010016 CONTEXT: hypervisor (XEN) rax: c2c2c2c2c2c2c2c2 rbx: ffff83003f4cc000 rcx: 0000000000000000 (XEN) Xen code around (__x86_indirect_thunk_rax+0xe/0x10): (XEN) ae e8 eb fb 48 89 04 24 90 e8 05 00 00 00 0f ae e8 eb fb 48 89 0c 24 (XEN) Xen stack trace from rsp=ffff82d080827d28: (XEN) c2c2c2c2c2c2c2c2 ffff82d080207588 ffff82d080827d68 0000000000000000 (XEN) Xen call trace: (XEN) [] __x86_indirect_thunk_rax+0xe/0x10 (XEN) [] setup_system_domains+0x18/0xab (XEN) [] __start_xen+0x1ea9/0x2935 (XEN) [] __high_start+0x53/0x55 (XEN) (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) GENERAL PROTECTION FAULT (XEN) [error_code=0000] (XEN) **************************************** UBSAN (which I happened to have active in my build at the time) identifies the problem explicitly: (XEN) Using APIC driver default (XEN) ================================================================================ (XEN) UBSAN: Undefined behaviour in /local/xen.git/xen/include/xsm/xsm.h:309:19 (XEN) member access within null pointer of type 'struct xsm_operations' (XEN) ----[ Xen-4.13-unstable x86_64 debug=y Not tainted ]---- "adjust system domain creation (and call it earlier on x86)" didn't account for the fact that domain_create() depends on XSM already being set up. There is nothing very interesting which xsm_multiboot_init() more than allocating memory, which means it is safe to move earlier during boot. The resulting boot now looks like: (XEN) Using APIC driver default (XEN) XSM Framework v1.0.0 initialized (XEN) Flask: 128 avtab hash slots, 283 rules. (XEN) Flask: 128 avtab hash slots, 283 rules. (XEN) Flask: 4 users, 3 roles, 38 types, 2 bools (XEN) Flask: 13 classes, 283 rules (XEN) Flask: Starting in enforcing mode. (XEN) ACPI: v5 SLEEP INFO: control[0:0], status[0:0] and (XEN) Using APIC driver default (XEN) XSM Framework v1.0.0 initialized (XEN) Initialising XSM SILO mode (XEN) ACPI: v5 SLEEP INFO: control[0:0], status[0:0] Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/setup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 6c3a7ed..d201191 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1533,6 +1533,8 @@ void __init noreturn __start_xen(unsigned long mbi_p) mmio_ro_ranges = rangeset_new(NULL, "r/o mmio ranges", RANGESETF_prettyprint_hex); + xsm_multiboot_init(module_map, mbi); + setup_system_domains(); acpi_boot_init(); @@ -1583,8 +1585,6 @@ void __init noreturn __start_xen(unsigned long mbi_p) init_IRQ(); - xsm_multiboot_init(module_map, mbi); - microcode_grab_module(module_map, mbi); timer_init();