From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60707C46CA2 for ; Mon, 18 Dec 2023 09:40:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+L1VV/d7kuG953WnefCOkUXKSHvswPCuE3ZSY+mYW88=; b=TB/c46Vyh1N/Dm vLvmcK5nyuImq0QOJ5MVYZrYv2LDi7WF1JA7C9BjSLZEo5bEZmC8mlEoUSCd109baE7MmMb8QKrkI IFj0rhSqsp/Jeb8XogUkWP3PlVhxAjRJChckzWHm8TmwVVClSvYbi6Hgex5EzGROSs0GBEEpdxxIy bnH7LTXzDARFnQIhB4SHW2a/xPVfKu8rw0bHgWedYx6hIRP3MCUGJ5CVMXhleJfSbAFwF52UvRpD3 hZVyqjnocRng1Qlo33eL+ebZLg2OW3ajJ8NY/iThLArxnCyJRQwriVJfo/KCc/wuIcagndLVJvfQZ jb5iTrQC/PXmEDPVv3KQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rFA6t-009hEU-0u; Mon, 18 Dec 2023 09:40:27 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rFA6q-009hDn-22 for linux-arm-kernel@lists.infradead.org; Mon, 18 Dec 2023 09:40:26 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id CE976CE0FD1; Mon, 18 Dec 2023 09:40:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EA4EC433C8; Mon, 18 Dec 2023 09:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702892422; bh=Mrq3Rom+ycuK3rYqygSdQOf1nhuvr7TGGuRUQdwXW4o=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=d1cgMwPE+mHEO6XaIWyYpfOXwShiBd1ZtX1G7yndxxkCSU7hY2TWxTtmJnMOU5sm1 DE8xX6zfVEsou1strAaEpgl6NmIp+N2GS6bjCI2jseZauyBvPxdzemgVbNCZ9+FXFq dzJ069KSL/DbmNQeuyuGm4eZenQJOU2u8MESgBLJO0UMfvSFpr6ip420efOv43LmT8 YZg63FE2hMYrAbEE2ye8vw+JpJSxq8XBXK7gNKlBnWg3S9EQV+G82Y0b1kePqMD6cE 47um83ilnA1rFbwQGBQNFtgiH5Vg/UXSuv6v+OFZHuwluJOlbFs9uiPyRCyN81haFw yyQ5sVoW/LASw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rFA6l-004z1D-Mr; Mon, 18 Dec 2023 09:40:19 +0000 Date: Mon, 18 Dec 2023 09:40:18 +0000 Message-ID: <86wmtbalx9.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v3 14/17] KVM: arm64: Macros for setting/clearing FGT bits In-Reply-To: <20231214100158.2305400-15-tabba@google.com> References: <20231214100158.2305400-1-tabba@google.com> <20231214100158.2305400-15-tabba@google.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tabba@google.com, kvmarm@lists.linux.dev, oliver.upton@linux.dev, broonie@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, eric.auger@redhat.com, jingzhangos@google.com, joey.gouly@arm.com, linux-arm-kernel@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231218_014025_007688_B20156BF X-CRM114-Status: GOOD ( 21.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 14 Dec 2023 10:01:54 +0000, Fuad Tabba wrote: > > There's a lot of boilerplate code for setting and clearing FGT > bits when activating guest traps. Refactor it into macros. These > macros will also be used in future patch series. > > No functional change intended. > > Signed-off-by: Fuad Tabba > --- > arch/arm64/kvm/hyp/include/hyp/switch.h | 60 +++++++++---------------- > 1 file changed, 21 insertions(+), 39 deletions(-) > > diff --git a/arch/arm64/kvm/hyp/include/hyp/switch.h b/arch/arm64/kvm/hyp/include/hyp/switch.h > index 17ce40f5b006..e223fc0d5193 100644 > --- a/arch/arm64/kvm/hyp/include/hyp/switch.h > +++ b/arch/arm64/kvm/hyp/include/hyp/switch.h > @@ -79,6 +79,23 @@ static inline void __activate_traps_fpsimd32(struct kvm_vcpu *vcpu) > clr |= ~hfg & __ ## reg ## _nMASK; \ > } while(0) > > +#define update_fgt_traps_cs(reg, clr, set) \ > + do { \ > + struct kvm_cpu_context *hctxt = \ > + &this_cpu_ptr(&kvm_host_data)->host_ctxt; \ > + u64 val, c = 0, s = 0; \ > + \ > + ctxt_sys_reg(hctxt, reg) = read_sysreg_s(SYS_ ## reg); \ > + compute_clr_set(vcpu, reg, c, s); \ You are referring to a variable name that is in the scope of the macro user, and not the macro itself. It is so fragile it isn't funny. Why don't you simply pass the vcpu as a parameter to the function? Another thing is that this read/write can be expensive. How about not doing anything when there is no change to the value of the sysreg? I'll see if I can come up with something. M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel