From patchwork Tue Sep 9 16:23:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 37142 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 D583820566 for ; Tue, 9 Sep 2014 16:27:51 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id b6sf57631077yha.9 for ; Tue, 09 Sep 2014 09:27:51 -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=BY2HmQIh6Fk8g3SoIY9NQOrl0fHdvHlAV0tTcacRBO8=; b=CAlt5NYkYD48yCsmEMdXii94ABaDJLAMJn1kq9A1S+ZD+CDR19FJYJi80FXCexvDIc ZTPaXgkVoKJ9l31j//O1awYl8Mi6QBpAKjb9KcedNxTWYRX6qQXQ2HfZ4rPU3rj3Yilg 1jqeZPIhuJn1Z65PgHIImuc9RHzhuxN5PYKpEjrXV1Mfe/qITMI/DZyt210VOIiEGu9s jEJzLTALptBWYKuqTDIUQOBpiLsVYXG0H7BZluvzt6aeZlZT/vnoEaE9iwHZ0zMEW5jS dWwo4W5pHw1flqjodq8GkE3OX6GoJjSXOxBn/bpFBHuoDqnqscJ0Sfky2N/6+KRytjqb glEA== X-Gm-Message-State: ALoCoQkTSn11TTYs/Z8TcAL1SJmNasPwhie5tyqfOz3++0EjCIMR5397tKYCqLLm/y4o0ceKdVll X-Received: by 10.52.182.66 with SMTP id ec2mr22273490vdc.0.1410280071637; Tue, 09 Sep 2014 09:27:51 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.207 with SMTP id u73ls1214053qge.34.gmail; Tue, 09 Sep 2014 09:27:51 -0700 (PDT) X-Received: by 10.52.185.193 with SMTP id fe1mr14200891vdc.31.1410280071545; Tue, 09 Sep 2014 09:27:51 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id k10si1637301vcv.84.2014.09.09.09.27.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Sep 2014 09:27:51 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so17311983vcb.39 for ; Tue, 09 Sep 2014 09:27:51 -0700 (PDT) X-Received: by 10.52.129.200 with SMTP id ny8mr3920302vdb.27.1410280071464; Tue, 09 Sep 2014 09:27:51 -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 uj3csp310546vcb; Tue, 9 Sep 2014 09:27:51 -0700 (PDT) X-Received: by 10.224.89.10 with SMTP id c10mr53889769qam.51.1410280070918; Tue, 09 Sep 2014 09:27:50 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id e109si15819262qgf.40.2014.09.09.09.27.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Sep 2014 09:27:50 -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 1XROF0-0003su-Jj; Tue, 09 Sep 2014 16:26:02 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XROEz-0003rh-9j for xen-devel@lists.xen.org; Tue, 09 Sep 2014 16:26:01 +0000 Received: from [85.158.143.35:31102] by server-2.bemta-4.messagelabs.com id 27/08-04525-81A2F045; Tue, 09 Sep 2014 16:26:00 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1410279957!12355182!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6075 invoked from network); 9 Sep 2014 16:26:00 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 9 Sep 2014 16:26:00 -0000 X-IronPort-AV: E=Sophos;i="5.04,492,1406592000"; d="scan'208";a="169814343" 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:17 -0400 Received: from drall.uk.xensource.com ([10.80.16.71]) by ukmail1.uk.xensource.com with smtp (Exim 4.69) (envelope-from ) id 1XROCK-0001uc-99; Tue, 09 Sep 2014 17:23:17 +0100 Received: by drall.uk.xensource.com (sSMTP sendmail emulation); Tue, 09 Sep 2014 17:23:16 +0100 From: Ian Campbell To: Date: Tue, 9 Sep 2014 17:23:07 +0100 Message-ID: <1410279788-27167-8-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: MIA1 Cc: julien.grall@linaro.org, tim@xen.org, Ian Campbell , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 8/9] xen: arm: handle remaining traps from userspace 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.180 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: CP14 dbg and general CP register access are both handled with unconditional injection of #undef from their respective handlers, so allow these even from 32-bit userspace on a 64-bit kernel. SMC32 and HVC32 should only come from a guest in AArch32 mode and SMC64 and HVC64 should only come from a guest in AArch64 mode. Add appropriate BUG_ONs to all cases. After this bad_trap is no longer used. Signed-off-by: Ian Campbell --- xen/arch/arm/traps.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index be02c68..78017db 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -1993,19 +1993,19 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) do_cp14_32(regs, hsr); break; case HSR_EC_CP14_DBG: - if ( !is_32bit_domain(current->domain) ) - goto bad_trap; + BUG_ON(!psr_mode_is_32bit(regs->cpsr)); do_cp14_dbg(regs, hsr); break; case HSR_EC_CP: - if ( !is_32bit_domain(current->domain) ) - goto bad_trap; + BUG_ON(!psr_mode_is_32bit(regs->cpsr)); do_cp(regs, hsr); break; case HSR_EC_SMC32: - inject_undef32_exception(regs); + BUG_ON(!psr_mode_is_32bit(regs->cpsr)); + inject_undef_exception(regs, hsr.len); break; case HSR_EC_HVC32: + BUG_ON(!psr_mode_is_32bit(regs->cpsr)); #ifndef NDEBUG if ( (hsr.iss & 0xff00) == 0xff00 ) return do_debug_trap(regs, hsr.iss & 0x00ff); @@ -2016,6 +2016,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) break; #ifdef CONFIG_ARM_64 case HSR_EC_HVC64: + BUG_ON(psr_mode_is_32bit(regs->cpsr)); #ifndef NDEBUG if ( (hsr.iss & 0xff00) == 0xff00 ) return do_debug_trap(regs, hsr.iss & 0x00ff); @@ -2025,7 +2026,7 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) do_trap_hypercall(regs, ®s->x16, hsr.iss); break; case HSR_EC_SMC64: - inject_undef64_exception(regs, hsr.len); + BUG_ON(psr_mode_is_32bit(regs->cpsr)); break; case HSR_EC_SYSREG: BUG_ON(psr_mode_is_32bit(regs->cpsr)); @@ -2040,7 +2041,6 @@ asmlinkage void do_trap_hypervisor(struct cpu_user_regs *regs) do_trap_data_abort_guest(regs, hsr); break; default: - bad_trap: printk("Hypervisor Trap. HSR=0x%x EC=0x%x IL=%x Syndrome=0x%"PRIx32"\n", hsr.bits, hsr.ec, hsr.len, hsr.iss); do_unexpected_trap("Hypervisor", regs);