From patchwork Thu Oct 18 13:20:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 149136 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1972794lji; Thu, 18 Oct 2018 06:23:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV607VC5EuUWnkPFFUvWDKJnpaehFY6keWmgdqciztCvx7JDVcoDo45xpz9/Dxzr0SIePjyQg X-Received: by 2002:a81:52ca:: with SMTP id g193-v6mr12039783ywb.41.1539869011015; Thu, 18 Oct 2018 06:23:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539869011; cv=none; d=google.com; s=arc-20160816; b=VqXxmb+xPYmVXz1DqoWlWkjc4Wz/bLdMFI9TcEfte4p+99bXn/yUek2pKFSvvEW4+x XF9TSpnxTI/qTk73r/spcCFQIQKnc2jh4KnVxkdEz31AR7LS1wkRKbKjNOXyjJtIl1Pf SvqXrfpia2Mrb3EiooAyHrIUIVcTzduHlGajcWLtvU/heZprEnC3E1qnFIXBCh3LDGXb hsaKja/M/M+3tsEi6XT21JEFVU0kfFh/SSKa6g6KD64kk6AFIYhthwj9fkCtCGsYFBiQ ck67CdosepPSq5gAYffSwazTeb1voLTga/+reZsYgQuDxu+IdYL55fdEPwyGApV80ITy /kFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=GmpCrz1NRqqaOKZ2LP/ufmdxxJf9BqUBncNHVyHFNBM=; b=MSDEryVtCO3+Ox0qao2EPWyI0W6nEAKf3DSGYNvKQwfbbsOAxr5z2R5nlYCvoRVYZr 7OGVdXSmlS4aXTMVQnzjZ2r+GVQpzAWG31zrAFsd4tSICWr6Ul0bQ87JB8DMeE8yjnqv rC/2UN7oLSW5kbkBanBWQuaUo3fKaMIdy7g42XBoPcmse39oZ8VfZBeoSvHv6ctu8tnD VuJg0CtQ+8JlpyrL/4E0OQiX9K82IpBaHrxpN9QDUlR6NT4jcsfBkuiRd0mbJvpTpKOD TZz6o8lSzMpID/zStU4YHoyL7kdIlOL9cw2+O/o5eUA+xYbIza3Kh0WlLIJv4slt0ZO2 v04w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f127-v6si8130109ywh.326.2018.10.18.06.23.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 06:23:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gD8Er-0002zL-DV; Thu, 18 Oct 2018 13:21:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gD8Eq-0002z4-CC for xen-devel@lists.xen.org; Thu, 18 Oct 2018 13:21:20 +0000 X-Inumbo-ID: e5b88ebb-d2d8-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id e5b88ebb-d2d8-11e8-a6a9-d7ebe60f679a; Thu, 18 Oct 2018 13:22:44 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E551B15BE; Thu, 18 Oct 2018 06:21:18 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2963B3F59C; Thu, 18 Oct 2018 06:21:18 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Thu, 18 Oct 2018 14:20:49 +0100 Message-Id: <20181018132109.31192-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181018132109.31192-1-julien.grall@arm.com> References: <20181018132109.31192-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 02/22] xen/arm: regs: Convert guest_mode to a static inline helper 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: Julien Grall , sstabellini@kernel.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" At the same time, switch the parameter guest_mode from int to bool Signed-off-by: Julien Grall Reviewed-by: Andrii Anisov --- xen/arch/arm/traps.c | 6 +++--- xen/include/asm-arm/regs.h | 22 ++++++++++++---------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 9eec51ea90..1b0b27434f 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -789,7 +789,7 @@ static const char *mode_string(uint32_t cpsr) static void show_registers_32(const struct cpu_user_regs *regs, const struct reg_ctxt *ctxt, - int guest_mode, + bool guest_mode, const struct vcpu *v) { @@ -866,7 +866,7 @@ static void show_registers_32(const struct cpu_user_regs *regs, #ifdef CONFIG_ARM_64 static void show_registers_64(const struct cpu_user_regs *regs, const struct reg_ctxt *ctxt, - int guest_mode, + bool guest_mode, const struct vcpu *v) { @@ -927,7 +927,7 @@ static void show_registers_64(const struct cpu_user_regs *regs, static void _show_registers(const struct cpu_user_regs *regs, const struct reg_ctxt *ctxt, - int guest_mode, + bool guest_mode, const struct vcpu *v) { print_xen_info(); diff --git a/xen/include/asm-arm/regs.h b/xen/include/asm-arm/regs.h index 2440edb29a..ddc6eba9ce 100644 --- a/xen/include/asm-arm/regs.h +++ b/xen/include/asm-arm/regs.h @@ -5,8 +5,10 @@ #ifndef __ASSEMBLY__ +#include #include #include +#include #include #define psr_mode(psr,m) (((psr) & PSR_MODE_MASK) == m) @@ -37,16 +39,16 @@ (psr_mode((r)->cpsr,PSR_MODE_EL0t) || usr_mode(r)) #endif -#define guest_mode(r) \ -({ \ - unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r); \ - /* Frame pointer must point into current CPU stack. */ \ - ASSERT(diff < STACK_SIZE); \ - /* If not a guest frame, it must be a hypervisor frame. */ \ - ASSERT((diff == 0) || hyp_mode(r)); \ - /* Return TRUE if it's a guest frame. */ \ - (diff == 0); \ -}) +static inline bool guest_mode(const struct cpu_user_regs *r) +{ + unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r); + /* Frame pointer must point into current CPU stack. */ + ASSERT(diff < STACK_SIZE); + /* If not a guest frame, it must be a hypervisor frame. */ + ASSERT((diff == 0) || hyp_mode(r)); + /* Return TRUE if it's a guest frame. */ + return (diff == 0); +} #define return_reg(v) ((v)->arch.cpu_info->guest_cpu_user_regs.r0)