From patchwork Tue Sep 9 16:23:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37136 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D21BA20566 for ; Tue, 9 Sep 2014 16:25:35 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id b6sf57694092yha.1 for ; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=RY2yIPH8LHDaHnwiCP4+PABHMibj3iIWbFX5S4Y54/Q=; b=cm0dvAxhbtBrLOsgIdwV0jdF6nhpog31OuVDlGHB0c+0sw6dtR3E1lmfiL8lYBblTI UmfnAsEn3mk7aQiME+doON9oNWU5C5w/jrHNIE3sbUDNNNOfTmBReSVhQCFuRdSrK9Ob pu7wctlBohmC367rwuqqhLGQ4fCwt+16rawfhnhXHvx7qBw2ah4p4WA/3lip+KxT0+wY XYa1eFZp6xr9AFFf8iszZ2LBl5RSeqoXJVMsVc0M1oBXSXlarIzvRIg5EEkpJ1bsi1+B hX1l5KGyFc1LOAtgs4U1yJWkXqbS7wEieVkx6tpxCDVfDkZfoPSvT83VvyYEmUk9v8Ii TP5A== X-Gm-Message-State: ALoCoQmSHzVgd0KxuBSXN6vFw/PQhAFSE6rbY8tOkEcuKg2me79wFDkDWjgv55XXb0cXpdv+Lxob X-Received: by 10.236.34.233 with SMTP id s69mr1459186yha.57.1410279935679; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.229 with SMTP id 92ls2292522qgn.98.gmail; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) X-Received: by 10.52.141.45 with SMTP id rl13mr5809097vdb.49.1410279935574; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id tf4si5369909vcb.1.2014.09.09.09.25.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 09:25:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id lf12so17136301vcb.20 for ; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) X-Received: by 10.220.118.136 with SMTP id v8mr2976421vcq.50.1410279935509; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp310203vcb; Tue, 9 Sep 2014 09:25:35 -0700 (PDT) X-Received: by 10.52.129.165 with SMTP id nx5mr25465391vdb.25.1410279935086; Tue, 09 Sep 2014 09:25:35 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id nv6si5348851vcb.47.2014.09.09.09.25.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Sep 2014 09:25:35 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XROCm-0003Kb-9R; Tue, 09 Sep 2014 16:23:44 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XROCk-0003KO-QM for xen-devel@lists.xen.org; Tue, 09 Sep 2014 16:23:42 +0000 Received: from [85.158.139.211:50861] by server-3.bemta-5.messagelabs.com id CB/DA-13873-E892F045; Tue, 09 Sep 2014 16:23:42 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-10.tower-206.messagelabs.com!1410279819!8114148!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 10177 invoked from network); 9 Sep 2014 16:23:41 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-10.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 9 Sep 2014 16:23:41 -0000 X-IronPort-AV: E=Sophos;i="5.04,492,1406592000"; d="scan'208";a="170606686" Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.3.181.6; Tue, 9 Sep 2014 12:23:11 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XROCE-0001uK-1O; Tue, 09 Sep 2014 17:23:11 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Tue, 09 Sep 2014 17:23:10 +0100 From: Ian Campbell To: Date: Tue, 9 Sep 2014 17:23:01 +0100 Message-ID: <1410279788-27167-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1410279730.8217.238.camel@kazak.uk.xensource.com> References: <1410279730.8217.238.camel@kazak.uk.xensource.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 2/9] xen: arm: Factor out psr_mode_is_user X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: This embodies the logic on arm64 that userspace can be either 32-bit or 64-bit. It will be used in other places shortly. Note that the logic differs slightly because the original (in inject_abt64_exception) knew that the kernel was 64-bit and could therefore assume that any 32-bit mode was userspace. Instead the refactored code explicitly checks for usr mode. Signed-off-by: Ian Campbell Reviewed-by: Julien Grall --- xen/arch/arm/traps.c | 9 +-------- xen/include/asm-arm/regs.h | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index c838b70..1b1d29f 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -451,14 +451,7 @@ static void inject_abt64_exception(struct cpu_user_regs *regs, .len = instr_len, }; - /* - * Trap may have been taken from EL0, which might be in AArch32 - * mode (PSR_MODE_BIT set), or in AArch64 mode (PSR_MODE_EL0t). - * - * Since we know the kernel must be 64-bit any trap from a 32-bit - * mode must have been from EL0. - */ - if ( psr_mode_is_32bit(regs->cpsr) || psr_mode(regs->cpsr,PSR_MODE_EL0t) ) + if ( psr_mode_is_user(regs) ) esr.ec = prefetch ? HSR_EC_INSTR_ABORT_LOWER_EL : HSR_EC_DATA_ABORT_LOWER_EL; else diff --git a/xen/include/asm-arm/regs.h b/xen/include/asm-arm/regs.h index 0951857..56d53d6 100644 --- a/xen/include/asm-arm/regs.h +++ b/xen/include/asm-arm/regs.h @@ -24,9 +24,17 @@ #ifdef CONFIG_ARM_32 #define hyp_mode(r) psr_mode((r)->cpsr,PSR_MODE_HYP) +#define psr_mode_is_user(r) usr_mode(r) #else #define hyp_mode(r) (psr_mode((r)->cpsr,PSR_MODE_EL2h) || \ psr_mode((r)->cpsr,PSR_MODE_EL2t)) + +/* + * Trap may have been taken from EL0, which might be in AArch32 usr + * mode, or in AArch64 mode (PSR_MODE_EL0t). + */ +#define psr_mode_is_user(r) \ + (psr_mode((r)->cpsr,PSR_MODE_EL0t) || usr_mode(r)) #endif #define guest_mode(r) \