From patchwork Wed Oct 31 18:12:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 149863 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp7128009ljp; Wed, 31 Oct 2018 11:16:54 -0700 (PDT) X-Google-Smtp-Source: AJdET5dqWCL68c0TNrN18sXePxERHjVbtxVEK3JCG02NNj5WTEsfuqjRsBHBR7IOASJn7b2oAkgL X-Received: by 2002:a25:aea5:: with SMTP id b37-v6mr4192930ybj.302.1541009814858; Wed, 31 Oct 2018 11:16:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541009814; cv=none; d=google.com; s=arc-20160816; b=skcUBaNIkHtc8ioljO8k9nM1ksnx6sQz+BRIjGB38r4LduiUVRK1QZ9RV/ZirgkMwx JzbyHLz4qrh4UlhaPTwAo97avq5VyfsUQiTEakqCm9o5SdnaZ4orJqogFRCKSBm79iYY lg5s90N+94QvVMYDS6vllZvoqGTBDkj/Yp+dsKR8b58dlw+UCNCG11kxsV/+2blatj7A 28ToMW+ViIIwhIG5/pwEVWc79Tahm+yLGafvSzn77TZmPsgLWnOOWSs53nHMJInB8xVe wFWPvm1PJNgdupmm26fHP6b5q4zUSAjXcQySYUKdzcRpmHpKFUMK3HdCjNse6U0LRS2Q eZ+w== 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=wkyyfD7/LhEEjcS3oz6vJ2lqAZqI1awc/mbLQwCz/ew=; b=x3A0k/Uo7CzRZq3m1wRDkAUlEpZ1GTWB07sGglBXezPWZF46n3Ub9pYNRuuDij5fzT RsqIFfhO/p4GNLZjYNBWkFpINbaxg4cjoTxGZMXvy9/76lLGJeJBrgF5YqERu0qLqeAv mJjTwt9ePPn+/Oa1k/c2GK8+Tx0UqidBiUwKQJlfYTIdduOULDSwiS6GhEgDeDj19p8p j7QQ7xMMDHkIvHmo2ZHUYbgCFyyBVUhxhehm9h5lXBR48GJMDGS5dX9wNTN2zLSYDFF7 OP1L+3hAxf2Hn14Pj5yPk6V9TyIzEAjbmFjYKp4n0vAkiQoB2s5tq8Zblldv0saJSqGv YWVg== 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 q125-v6si6463845ywq.248.2018.10.31.11.16.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Oct 2018 11:16:54 -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 1gHuzc-0004Mx-MH; Wed, 31 Oct 2018 18:13:24 +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 1gHuzb-0004Mi-G0 for xen-devel@lists.xen.org; Wed, 31 Oct 2018 18:13:23 +0000 X-Inumbo-ID: a707c1e4-dd38-11e8-8aed-12d6303a7972 Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id a707c1e4-dd38-11e8-8aed-12d6303a7972; Wed, 31 Oct 2018 18:13:22 +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 31F5A80D; Wed, 31 Oct 2018 11:13:22 -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 46AAD3F6A8; Wed, 31 Oct 2018 11:13:21 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Wed, 31 Oct 2018 18:12:54 +0000 Message-Id: <20181031181313.8028-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181031181313.8028-1-julien.grall@arm.com> References: <20181031181313.8028-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH v2 02/21] 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, andrii_anisov@epam.com 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 --- Changes in v2: - Add andrii's reviewed-by --- 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 e8fa760607..b9323672fc 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)