From patchwork Fri Mar 31 13:07:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Chen X-Patchwork-Id: 9656359 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE8B060351 for ; Fri, 31 Mar 2017 13:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFC3827F93 for ; Fri, 31 Mar 2017 13:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C421728643; Fri, 31 Mar 2017 13:11:01 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2606827F93 for ; Fri, 31 Mar 2017 13:11:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctwI3-0007wP-Pw; Fri, 31 Mar 2017 13:08:31 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctwI1-0007w8-Id for xen-devel@lists.xen.org; Fri, 31 Mar 2017 13:08:29 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id 7F/93-03642-CC45ED85; Fri, 31 Mar 2017 13:08:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAA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.messagelabs.com!1490965707!42013281!1 X-Originating-IP: [40.107.5.76] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27814 invoked from network); 31 Mar 2017 13:08:27 -0000 Received: from mail-eopbgr50076.outbound.protection.outlook.com (HELO EUR03-VE1-obe.outbound.protection.outlook.com) (40.107.5.76) by server-15.tower-27.messagelabs.com with AES256-SHA256 encrypted SMTP; 31 Mar 2017 13:08:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ORTf0/ZlKrYk624lWGdcxN8Du2OVdo3WzjnACyn298k=; b=HGzrEEA8bNuzgexCEzgYusvpVCZaNWvxRRVvGTC/FgWhd2m5XJYqWX0hwJSPjOTroB0kllWPdMSo70DaXv6trdBKE9PCPsMN/UpSCjHUaipYeUurczMqpiHqODaYLnLHn918tnRxHcOw7GgT5uZrm9Ng6bnHgGNLjVPPMuwX25k= Received: from DB5PR08CA0050.eurprd08.prod.outlook.com (10.166.166.146) by AM5PR0801MB1665.eurprd08.prod.outlook.com (10.169.246.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10; Fri, 31 Mar 2017 13:08:26 +0000 Received: from DB5EUR03FT054.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::204) by DB5PR08CA0050.outlook.office365.com (2a01:111:e400:c576::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1005.10 via Frontend Transport; Fri, 31 Mar 2017 13:08:26 +0000 Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB5EUR03FT054.mail.protection.outlook.com (10.152.20.248) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1005.5 via Frontend Transport; Fri, 31 Mar 2017 13:08:25 +0000 Received: from P300.p300.shanghai.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 31 Mar 2017 14:08:05 +0100 From: Wei Chen To: Date: Fri, 31 Mar 2017 21:07:41 +0800 Message-ID: <1490965679-619-2-git-send-email-Wei.Chen@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1490965679-619-1-git-send-email-Wei.Chen@arm.com> References: <1490965679-619-1-git-send-email-Wei.Chen@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(39840400002)(39410400002)(39400400002)(39850400002)(39860400002)(39450400003)(2980300002)(438002)(199003)(189002)(5003940100001)(86362001)(189998001)(50226002)(36756003)(76176999)(50986999)(305945005)(110136004)(47776003)(5660300001)(38730400002)(54906002)(106466001)(4326008)(8676002)(104016004)(48376002)(77096006)(2351001)(2906002)(8936002)(356003)(6666003)(2950100002)(6916009); DIR:OUT; SFP:1101; SCL:1; SRVR:AM5PR0801MB1665; H:nebula.arm.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB5EUR03FT054; 1:aKxQ0owOyJLc8w9JIanI+XKKdYAsVgZEZjAvS4JQjA2OLiosW9vyO0ccJht3WqPnAYsu6F5YAzlAMwtZpivRSB18+AsIHS1B2EU/bmfInMcC0XwJ2Ey4dR+huboYja1oqoyzydgKqHpWETBBNprQwkOK8yEncUrHsISePH/M3yVD0LjcDq/z7t1J8+QJ/9FyJKWJP4KUo4MiIpfGQfKBGIsxow7+efGEIVh7GVTBcdhksZfLAevf+zWY7xoBC9xPHkGaXNiMJYRupEzuDqA2R6V0bgoK84+pxRlsd8bPV3bioY2OH8VGpsNcZ8Zi9e05ytOb8BXtil91c+82xjcdynYLD+jZhMmynNI1ZVQudoLSX1eKC5pJGK47jdchR1TYRs2jhFPpMEm9IiGR7Ix/IFww+2wvTD+PSI6IfWdmADoiDqJq20PKo83mvBK+imXgBMA7CKP9yu6L5QLmhqqBOXS++BCp06F/HRP0gVbOe+8AJnU9n0+m7HTtSQTWS5YvRmMHcbrmv//wrY1OTK6q/ng1trFExTpOChaLyltfNk0MQBiK8dvUF88CpH7T0pqxAvUOiko1NvLLsh3fWx7mT/bq7ztQMtoXxfH9Kk3a4OKB1i59dwm3OA4eagBiBrk6 X-MS-Office365-Filtering-Correlation-Id: 6c7ae0ad-ffc8-401e-f50e-08d47837047e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081)(201702281549075); SRVR:AM5PR0801MB1665; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1665; 3:bkWfOG4rVNvQ5S3Cz0OPdH0x0FwYCBMjKuaI131gxCKx+7E8dyhrjoCsADsXRqmYRvLoHv87A2WzD3OSbPrlw2YMDKLkPnDVuW4WnS/YNVUHbrrASA8Eu7b1LAHlMHTYKoGoev608aARWBTgbENwLiO1tybu+qArYSvndKw10ofLjc1Ud4PKLeVPpsb8vtzKsmVmQIlRCqXcIypXVhDrdWYoejvAk+NakTAL+e8ZiiZEUVBAFnaBrwnpI1GbyVF4WS7hL8N3Je9O0QFij/hAIKRsu7Cj4IFBL6djvBJvQQQQHKMGJNhg+cfDKjU/wScTl1VzDCLXIYhLa8XBMEV+gT9tYfqSqIaIAhv/8EgyieFwTUZ0tmfX9EQHe0ALoDuWqeBhviLlafLDsKnWxdt/ZNwZBNKjsfIbovhMPxvC6swDwNl+xGz4aya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ChtnAUYd/Fn2hVPlugB4p01R5VlaH84b5j02Vj+uz8UMMAOZeJRyY4yNapl56VyvRmo99YX02e6uo0K0F7ACcYqckfcAxzSR/fNvGalUhQh/DErFrhaTc2X X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(13024025)(5005006)(13023025)(8121501046)(13013025)(13020025)(3002001)(10201501046)(93006095)(93004095)(6055026)(6041248)(20161123562025)(20161123555025)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(6072148); SRVR:AM5PR0801MB1665; BCL:0; PCL:0; RULEID:; SRVR:AM5PR0801MB1665; X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1665; 4:Hu1c4FqbvOHvJj4Kq4qxWUqhQxqsGLfx1sIKw/39YaIav0lSW3OauVsXKQzoDXuWvp59Vf4yhnVByrGBNwyjjKv5eYt9Zm8QQ/eDckmNzz20LOF0MxlP1vZaUjOfWu1m91RnfNqKEaMFenItXiruyr157wTP+dSDPCdOw+WjoEz/828D+bRSrNtaoYj1Kc5dYQHISXuwseAwzFbmQGYMN+hVh1zW0EO9ZIzSuULoQQE46FNVgfYVLou5WOm1UbHmDDriCx+jzKEkmWnaQbTl7DKbFged591Tr+A4xis65nXq//agzy0X2EJglfJi+eJnCzDhyoKoSajzWTfbzmQvyrk48TuJTFDd+KRXdBmmzkV/YHQHRWAZUCa0dQHq79BXog1RKnieul98JmgLK87qqV/MM0lLJqWiPfVy/Gej8Msmjm1cRTTgNpQGmZSyKAPgQV+EMnXi6xANAGjXo/tPuH97d+ZUtB+XHMMRfp26B5iVxK8DqThMdgCyACxVjvfC03lYb59jWEMh5/GnmvepnGqMj88OutLdQIg6oxZ/TgF7LvobwOk99i/4OmjzMQk5zSyv4HzDXBOizToE7IwRJRhwd3s3msliNlIDf2OswahuZhPHuU+l9Rhl8ROkD3GfFKt9CX2esbgaUH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wvUaMQkm8xrT8Ak3aP8ymMK9NekI0XPsNnvXh5myg18G+eYfAiWU0U3TaRKH3lM3Ar+BaoYJ9bNw3DNubuT42o+S/vLw4/Wr8/loD8NaksxS/3w6a39F9mQsyHP+YXy+0bI1HBTBC4TFx3HjSgDn8RsTcAnZa/s0xs73n2 X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1665; 6:4UFnjw+TpCC/whWhJKUjRAVaRfoqies021uN434vBnI2Z+IYpJoy6bAXmAHjPI+xFub8nfs9gH/L5X4fBWN1mfFlzJiAgue2XJX8WEsSQ7D5YaLeQFCfM36Vq75wk4DDGYINCZuaYVqnb+UiHcx1UTfUy08GqT25RTw8FLzduFscEncCsErUfCf4vzLBQvCWBOosuBxBAR5GwcuK4t9WgLgih6o3OyDrI8IWQxSjhb3hc06oTbkMKwCk5XTmgi65l/6YY6u9NCmRvp1hGEx2gxmcCcBk1BtDXuM37Mkm+91lGFUlVRdBfXsGH7d6Zlf/MJ0irQANFG8QJQgzntHck7WJ+eY28U955RaYmMad48eA6JN0CmDzpdI0Vc44aKFGF1pz6OmT3ijMUqC3bzRl4A==; 5:B3aW5o4nuWxtwWb2enL4KsP2F5m+JNUocVC/FqTXi1QUjLp3ekAyABiWycayOWZsesrOVwtidOiBtptWow/Xon+c2D9svT1Df+pYSNpIFEvU18E7ypeoWhV4kXyllLDHQrv8hT7/Gj3g88jA3vrxrmodIudnunK4N16VD78WZus=; 24:IRyDULj0SXibPi/6qKqXKI4fUJOs/owOIi7wa5DjKMPnMrsiCGe/l06sxyCVwh2QiBQCamFYbvedwXAj8a4fVWJeuafHpZdvvH8Dr+EvAdA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM5PR0801MB1665; 7:tNfPnOWvUIqwoSnL0XTXXDUm2LLsxZPYLmxchEauKFgVPkAjt/ZjiYOlvbsrYl+fEr/jMVx+yURUU9jSF2KiFgmrYTBBjp9bzvGr+ivBwaQtgOyBxzV0PqSqacHnUabJE4Fv8rpnVpUJflRU0XPTr179hqWGtKLS7oAvNHk2sw0tvaiDdHCwYLXP3IE7rTjHy3WPVzQlzj8eQJUXUu61hiqU224LfRWM25imvusnk92v0aZBgh+mufGmIBrTT+ZDo3iHsC7L0+MnHV72HHBmfewHiW5d+WIXYma8mURCpiFdmyNOMyUsFzpuSP4BULCRWHj73UKaATV85SkAgCuhzA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2017 13:08:25.7546 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1665 Cc: sstabellini@kernel.org, wei.chen@arm.com, steve.capper@arm.com, Kaly.Xin@arm.com, julien.grall@arm.com, nd@arm.com Subject: [Xen-devel] [PATCH v3 01/19] xen/arm: Save ESR_EL2 to avoid using mismatched value in syndrome check X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Xen will do exception syndrome check while some types of exception take place in EL2. The syndrome check code read the ESR_EL2 register directly, but in some situation this register maybe overridden by nested exception. For example, if we re-enable IRQ before reading ESR_EL2 which means Xen may enter in IRQ exception mode and return the processor with clobbered ESR_EL2 (See ARM ARM DDI 0487A.j D7.2.25) In this case the guest exception syndrome has been overridden, we will check the syndrome for guest sync exception with an incorrect ESR_EL2 value. So we want to save ESR_EL2 to cpu_user_regs as soon as the exception takes place in EL2 to avoid using an incorrect syndrome value. In order to save ESR_EL2, we added a 32-bit member hsr to cpu_user_regs. But while saving registers in trap entry, we use stp to save ELR and CPSR at the same time through 64-bit general registers. If we keep this code, the hsr will be overridden by upper 32-bit of CPSR. So adjust the code to use str to save ELR in a separate instruction and use stp to save CPSR and HSR at the same time through 32-bit general registers. This change affects the registers restore in trap exit, we can't use the ldp to restore ELR and CPSR from stack at the same time. We have to use ldr to restore them separately. Signed-off-by: Wei Chen Reviewed-by: Julien Grall Reviewed-by: Stefano Stabellini --- Note: This patch is a bug fix, this bug affects the 4.8 and 4.7 source trees too. v2->v3: 1. Add note to the commit message. 2. Read ESR_EL2 value from vCPU context instead of reading from register directly in the places where use the ESR_EL2 value. --- xen/arch/arm/arm32/asm-offsets.c | 1 + xen/arch/arm/arm32/entry.S | 3 +++ xen/arch/arm/arm64/asm-offsets.c | 1 + xen/arch/arm/arm64/entry.S | 13 +++++++++---- xen/arch/arm/arm64/traps.c | 2 +- xen/arch/arm/traps.c | 4 ++-- xen/include/asm-arm/arm32/processor.h | 2 +- xen/include/asm-arm/arm64/processor.h | 3 +-- 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c index f8e6b53..5b543ab 100644 --- a/xen/arch/arm/arm32/asm-offsets.c +++ b/xen/arch/arm/arm32/asm-offsets.c @@ -26,6 +26,7 @@ void __dummy__(void) OFFSET(UREGS_lr, struct cpu_user_regs, lr); OFFSET(UREGS_pc, struct cpu_user_regs, pc); OFFSET(UREGS_cpsr, struct cpu_user_regs, cpsr); + OFFSET(UREGS_hsr, struct cpu_user_regs, hsr); OFFSET(UREGS_LR_usr, struct cpu_user_regs, lr_usr); OFFSET(UREGS_SP_usr, struct cpu_user_regs, sp_usr); diff --git a/xen/arch/arm/arm32/entry.S b/xen/arch/arm/arm32/entry.S index 2a6f4f0..2187226 100644 --- a/xen/arch/arm/arm32/entry.S +++ b/xen/arch/arm/arm32/entry.S @@ -23,6 +23,9 @@ add r11, sp, #UREGS_kernel_sizeof+4; \ str r11, [sp, #UREGS_sp]; \ \ + mrc CP32(r11, HSR); /* Save exception syndrome */ \ + str r11, [sp, #UREGS_hsr]; \ + \ mrs r11, SPSR_hyp; \ str r11, [sp, #UREGS_cpsr]; \ and r11, #PSR_MODE_MASK; \ diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c index 69ea92a..ce24e44 100644 --- a/xen/arch/arm/arm64/asm-offsets.c +++ b/xen/arch/arm/arm64/asm-offsets.c @@ -27,6 +27,7 @@ void __dummy__(void) OFFSET(UREGS_SP, struct cpu_user_regs, sp); OFFSET(UREGS_PC, struct cpu_user_regs, pc); OFFSET(UREGS_CPSR, struct cpu_user_regs, cpsr); + OFFSET(UREGS_ESR_el2, struct cpu_user_regs, hsr); OFFSET(UREGS_SPSR_el1, struct cpu_user_regs, spsr_el1); diff --git a/xen/arch/arm/arm64/entry.S b/xen/arch/arm/arm64/entry.S index c181b5e..02802c0 100644 --- a/xen/arch/arm/arm64/entry.S +++ b/xen/arch/arm/arm64/entry.S @@ -121,9 +121,13 @@ lr .req x30 // link register stp lr, x21, [sp, #UREGS_LR] - mrs x22, elr_el2 - mrs x23, spsr_el2 - stp x22, x23, [sp, #UREGS_PC] + mrs x21, elr_el2 + str x21, [sp, #UREGS_PC] + + add x21, sp, #UREGS_CPSR + mrs x22, spsr_el2 + mrs x23, esr_el2 + stp w22, w23, [x21] .endm @@ -307,7 +311,8 @@ ENTRY(return_to_new_vcpu64) return_from_trap: msr daifset, #2 /* Mask interrupts */ - ldp x21, x22, [sp, #UREGS_PC] // load ELR, SPSR + ldr x21, [sp, #UREGS_PC] // load ELR + ldr w22, [sp, #UREGS_CPSR] // load SPSR pop x0, x1 pop x2, x3 diff --git a/xen/arch/arm/arm64/traps.c b/xen/arch/arm/arm64/traps.c index 8e89376..36b3a30 100644 --- a/xen/arch/arm/arm64/traps.c +++ b/xen/arch/arm/arm64/traps.c @@ -32,7 +32,7 @@ static const char *handler[]= { asmlinkage void do_bad_mode(struct cpu_user_regs *regs, int reason) { - union hsr hsr = { .bits = READ_SYSREG32(ESR_EL2) }; + union hsr hsr = { .bits = regs->hsr }; printk("Bad mode in %s handler detected\n", handler[reason]); printk("ESR=0x%08"PRIx32": EC=%"PRIx32", IL=%"PRIx32", ISS=%"PRIx32"\n", diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 614501f..6137272 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -843,7 +843,7 @@ static void _show_registers(struct cpu_user_regs *regs, printk(" HCR_EL2: %016"PRIregister"\n", READ_SYSREG(HCR_EL2)); printk(" TTBR0_EL2: %016"PRIx64"\n", READ_SYSREG64(TTBR0_EL2)); printk("\n"); - printk(" ESR_EL2: %08"PRIx32"\n", READ_SYSREG32(ESR_EL2)); + printk(" ESR_EL2: %08"PRIx32"\n", regs->hsr); printk(" HPFAR_EL2: %016"PRIregister"\n", READ_SYSREG(HPFAR_EL2)); #ifdef CONFIG_ARM_32 @@ -2641,7 +2641,7 @@ static void enter_hypervisor_head(struct cpu_user_regs *regs) asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) { - const union hsr hsr = { .bits = READ_SYSREG32(ESR_EL2) }; + const union hsr hsr = { .bits = regs->hsr }; enter_hypervisor_head(regs); diff --git a/xen/include/asm-arm/arm32/processor.h b/xen/include/asm-arm/arm32/processor.h index db3b17b..f6d5df3 100644 --- a/xen/include/asm-arm/arm32/processor.h +++ b/xen/include/asm-arm/arm32/processor.h @@ -37,7 +37,7 @@ struct cpu_user_regs uint32_t pc, pc32; }; uint32_t cpsr; /* Return mode */ - uint32_t pad0; /* Doubleword-align the kernel half of the frame */ + uint32_t hsr; /* Exception Syndrome */ /* Outer guest frame only from here on... */ diff --git a/xen/include/asm-arm/arm64/processor.h b/xen/include/asm-arm/arm64/processor.h index b0726ff..24f836b 100644 --- a/xen/include/asm-arm/arm64/processor.h +++ b/xen/include/asm-arm/arm64/processor.h @@ -66,8 +66,7 @@ struct cpu_user_regs /* Return address and mode */ __DECL_REG(pc, pc32); /* ELR_EL2 */ uint32_t cpsr; /* SPSR_EL2 */ - - uint32_t pad0; /* Align end of kernel frame. */ + uint32_t hsr; /* ESR_EL2 */ /* Outer guest frame only from here on... */