From: Marc Zyngier <marc.zyngier@arm.com> To: "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com> Cc: kvm@vger.kernel.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Andre Przywara <andre.przywara@arm.com>, Daniel Lezcano <daniel.lezcano@linaro.org>, kvmarm@lists.cs.columbia.edu, Shaokun Zhang <zhangshaokun@hisilicon.com>, Masahiro Yamada <yamada.masahiro@socionext.com>, linux-arm-kernel@lists.infradead.org, Zenghui Yu <yuzenghui@huawei.com>, Colin Ian King <colin.king@canonical.com>, Dave Martin <Dave.Martin@arm.com> Subject: [PATCH 10/27] KVM: arm64: Reuse sys_reg() macro when searching the trap table Date: Fri, 22 Feb 2019 16:25:48 +0000 [thread overview] Message-ID: <20190222162605.5054-11-marc.zyngier@arm.com> (raw) In-Reply-To: <20190222162605.5054-1-marc.zyngier@arm.com> Instead of having an open-coded macro, reuse the sys_reg() macro that does the exact same thing (the encoding is slightly different, but the ordering property is the same). Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> --- arch/arm64/kvm/sys_regs.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index e3e37228ae4e..1a5bea4285e4 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -965,6 +965,10 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return true; } +#define reg_to_encoding(x) \ + sys_reg((u32)(x)->Op0, (u32)(x)->Op1, \ + (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2); + /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */ #define DBG_BCR_BVR_WCR_WVR_EL1(n) \ { SYS_DESC(SYS_DBGBVRn_EL1(n)), \ @@ -1820,30 +1824,19 @@ static const struct sys_reg_desc *get_target_table(unsigned target, } } -#define reg_to_match_value(x) \ - ({ \ - unsigned long val; \ - val = (x)->Op0 << 14; \ - val |= (x)->Op1 << 11; \ - val |= (x)->CRn << 7; \ - val |= (x)->CRm << 3; \ - val |= (x)->Op2; \ - val; \ - }) - static int match_sys_reg(const void *key, const void *elt) { const unsigned long pval = (unsigned long)key; const struct sys_reg_desc *r = elt; - return pval - reg_to_match_value(r); + return pval - reg_to_encoding(r); } static const struct sys_reg_desc *find_reg(const struct sys_reg_params *params, const struct sys_reg_desc table[], unsigned int num) { - unsigned long pval = reg_to_match_value(params); + unsigned long pval = reg_to_encoding(params); return bsearch((void *)pval, table, num, sizeof(table[0]), match_sys_reg); } -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <marc.zyngier@arm.com> To: "Paolo Bonzini" <pbonzini@redhat.com>, "Radim Krčmář" <rkrcmar@redhat.com> Cc: Julien Thierry <julien.thierry@arm.com>, kvm@vger.kernel.org, Ard Biesheuvel <ard.biesheuvel@linaro.org>, Andre Przywara <andre.przywara@arm.com>, Daniel Lezcano <daniel.lezcano@linaro.org>, Christoffer Dall <christoffer.dall@arm.com>, kvmarm@lists.cs.columbia.edu, Shaokun Zhang <zhangshaokun@hisilicon.com>, Masahiro Yamada <yamada.masahiro@socionext.com>, James Morse <james.morse@arm.com>, linux-arm-kernel@lists.infradead.org, Zenghui Yu <yuzenghui@huawei.com>, Colin Ian King <colin.king@canonical.com>, Dave Martin <Dave.Martin@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com> Subject: [PATCH 10/27] KVM: arm64: Reuse sys_reg() macro when searching the trap table Date: Fri, 22 Feb 2019 16:25:48 +0000 [thread overview] Message-ID: <20190222162605.5054-11-marc.zyngier@arm.com> (raw) In-Reply-To: <20190222162605.5054-1-marc.zyngier@arm.com> Instead of having an open-coded macro, reuse the sys_reg() macro that does the exact same thing (the encoding is slightly different, but the ordering property is the same). Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Acked-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> --- arch/arm64/kvm/sys_regs.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index e3e37228ae4e..1a5bea4285e4 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -965,6 +965,10 @@ static bool access_pmuserenr(struct kvm_vcpu *vcpu, struct sys_reg_params *p, return true; } +#define reg_to_encoding(x) \ + sys_reg((u32)(x)->Op0, (u32)(x)->Op1, \ + (u32)(x)->CRn, (u32)(x)->CRm, (u32)(x)->Op2); + /* Silly macro to expand the DBG{BCR,BVR,WVR,WCR}n_EL1 registers in one go */ #define DBG_BCR_BVR_WCR_WVR_EL1(n) \ { SYS_DESC(SYS_DBGBVRn_EL1(n)), \ @@ -1820,30 +1824,19 @@ static const struct sys_reg_desc *get_target_table(unsigned target, } } -#define reg_to_match_value(x) \ - ({ \ - unsigned long val; \ - val = (x)->Op0 << 14; \ - val |= (x)->Op1 << 11; \ - val |= (x)->CRn << 7; \ - val |= (x)->CRm << 3; \ - val |= (x)->Op2; \ - val; \ - }) - static int match_sys_reg(const void *key, const void *elt) { const unsigned long pval = (unsigned long)key; const struct sys_reg_desc *r = elt; - return pval - reg_to_match_value(r); + return pval - reg_to_encoding(r); } static const struct sys_reg_desc *find_reg(const struct sys_reg_params *params, const struct sys_reg_desc table[], unsigned int num) { - unsigned long pval = reg_to_match_value(params); + unsigned long pval = reg_to_encoding(params); return bsearch((void *)pval, table, num, sizeof(table[0]), match_sys_reg); } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-02-22 16:25 UTC|newest] Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-22 16:25 [GIT PULL] KVM/arm updates for Linux v5.1 Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 01/27] clocksource/arm_arch_timer: Store physical timer IRQ number for KVM on VHE Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 02/27] arm/arm64: KVM: Introduce kvm_call_hyp_ret() Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 03/27] arm64: KVM: Allow for direct call of HYP functions when using VHE Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 04/27] arm64: KVM: Drop VHE-specific HYP call stub Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 05/27] ARM: KVM: Teach some form of type-safety to kvm_call_hyp Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 06/27] arm/arm64: KVM: Statically configure the host's view of MPIDR Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 07/27] KVM: arm/arm64: Factor out VMID into struct kvm_vmid Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 08/27] KVM: arm/arm64: Simplify bg_timer programming Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 09/27] KVM: arm64: Fix ICH_ELRSR_EL2 sysreg naming Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier [this message] 2019-02-22 16:25 ` [PATCH 10/27] KVM: arm64: Reuse sys_reg() macro when searching the trap table Marc Zyngier 2019-02-22 16:25 ` [PATCH 11/27] KVM: arm/arm64: consolidate arch timer trap handlers Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 12/27] KVM: arm/arm64: timer: Rework data structures for multiple timers Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 13/27] KVM: arm/arm64: arch_timer: Assign the phys timer on VHE systems Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 14/27] KVM: arm/arm64: Rework the timer code to use a timer_map Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 15/27] KVM: arm/arm64: Move kvm_is_write_fault to header file Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 16/27] arm64: KVM: Expose sanitised cache type register to guest Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 17/27] arm64: KVM: Describe data or unified caches as having 1 set and 1 way Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 18/27] KVM: arm/arm64: arch_timer: Mark physical interrupt active when a virtual interrupt is pending Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 19/27] KVM: arm/arm64: Fix TRACE_INCLUDE_PATH Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 20/27] KVM: arm/arm64: Remove -I. header search paths Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:25 ` [PATCH 21/27] KVM: arm/arm64: Prefix header search paths with $(srctree)/ Marc Zyngier 2019-02-22 16:25 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 22/27] KVM: arm/arm64: Update MAINTAINERS entries Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 23/27] KVM: arm/arm64: fix spelling mistake: "auxilary" -> "auxiliary" Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 24/27] KVM: arm64: Fix comment for KVM_PHYS_SHIFT Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 25/27] KVM: arm/arm64: Remove unused gpa_end variable Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 26/27] KVM: arm/arm64: Remove unused timer variable Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:26 ` [PATCH 27/27] arm64: KVM: Fix architecturally invalid reset value for FPEXC32_EL2 Marc Zyngier 2019-02-22 16:26 ` Marc Zyngier 2019-02-22 16:45 ` [GIT PULL] KVM/arm updates for Linux v5.1 Paolo Bonzini 2019-02-22 16:45 ` Paolo Bonzini
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20190222162605.5054-11-marc.zyngier@arm.com \ --to=marc.zyngier@arm.com \ --cc=Dave.Martin@arm.com \ --cc=andre.przywara@arm.com \ --cc=ard.biesheuvel@linaro.org \ --cc=colin.king@canonical.com \ --cc=daniel.lezcano@linaro.org \ --cc=kvm@vger.kernel.org \ --cc=kvmarm@lists.cs.columbia.edu \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=pbonzini@redhat.com \ --cc=rkrcmar@redhat.com \ --cc=yamada.masahiro@socionext.com \ --cc=yuzenghui@huawei.com \ --cc=zhangshaokun@hisilicon.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.