mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Marc Zyngier <maz@kernel.org>, James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Oliver Upton <oliver.upton@linux.dev>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev,
	kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH 0/2] KVM: arm64: syreg cleanups/fixes
Date: Wed, 21 Dec 2022 18:06:09 +0000	[thread overview]
Message-ID: <20221221-kvm-sysreg-cleanup-v1-0-112ddb14fb4e@kernel.org> (raw)

While looking at the KVM ID register handling I realised that the
ARM64_FEATURE_MASK() macro which is extensively used there assumes that
all ID register fields are 4 bits wide which is sadly no longer true.
Fixing this just in the macro results in something that asked for
further cleanup so I went and did that.  The end result is this series
which replaces code like:

	val &= ~ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_GIC);
	val |= FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64PFR0_EL1_GIC), 1);

with:

	val &= ~ID_AA64PFR0_EL1_GIC_MASK;
	val |= SYS_FIELD_PREP(ID_AA64PFR0_EL1, GIC, 1);

which is if nothing else shorter with less boilerplate, and as a side
effect removes the assumption that all feature fields are 4 bits wide
that was what got me started.

At least one other assumption that fields are 4 bits wide exists in the
pKVM code in get_restricture_features_unsigned().  I have left this for
now since it is a much less mechanical change so probably belongs in a
separate series, I will work on that separately.  The one register I am
aware of with fields that are impacted is ID_AA64SMFR0_EL1 so should
only become relevant in the event that we expose SME to pKVM guests.

There are some similar changes to use SYS_FIELD_ that could be done in
the GIC code but this is already far larger than would be expected for
the original fix and updating the GIC code will need the GIC registers
converting to generation which would really increase the size of the
series.  The GIC also doesn't use ARM64_FEATURE_MASK() which was the
original issue.  I will also send updates for the GIC separately.

Since this is highly likely to generate conflicts I'm posting during the
merge window to try to get a head start on review, I'll rebase against
-rc1 once that appears.

To: Marc Zyngier <maz@kernel.org>
To: James Morse <james.morse@arm.com>
To: Alexandru Elisei <alexandru.elisei@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Oliver Upton <oliver.upton@linux.dev>
To: Catalin Marinas <catalin.marinas@arm.com>
To: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: kvmarm@lists.linux.dev
Cc: kvmarm@lists.cs.columbia.edu
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

---
Mark Brown (2):
      KVM: arm64: Convert non-GIC code to SYS_FIELD_{GET,PREP}
      KVM: arm64: Remove use of ARM64_FEATURE_MASK()

 arch/arm64/include/asm/sysreg.h                |   3 -
 arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 120 ++++++++++++-------------
 arch/arm64/kvm/hyp/nvhe/pkvm.c                 |  40 ++++-----
 arch/arm64/kvm/hyp/nvhe/sys_regs.c             |  26 +++---
 arch/arm64/kvm/pmu-emul.c                      |   2 +-
 arch/arm64/kvm/sys_regs.c                      |  66 +++++++-------
 6 files changed, 128 insertions(+), 129 deletions(-)
---
base-commit: e45fb347b630ee76482fe938ba76cf8eab811290
change-id: 20221221-kvm-sysreg-cleanup-dd618baabebb

Best regards,
-- 
Mark Brown <broonie@kernel.org>

             reply	other threads:[~2022-12-21 18:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-21 18:06 Mark Brown [this message]
2022-12-21 18:06 ` [PATCH 1/2] KVM: arm64: Convert non-GIC code to SYS_FIELD_{GET,PREP} Mark Brown
2022-12-21 18:06 ` [PATCH 2/2] KVM: arm64: Remove use of ARM64_FEATURE_MASK() Mark Brown
2022-12-22 12:23   ` Marc Zyngier
2022-12-22 12:34     ` Mark Brown

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=20221221-kvm-sysreg-cleanup-v1-0-112ddb14fb4e@kernel.org \
    --to=broonie@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®