From: Gavin Shan <gshan@redhat.com>
To: kvmarm@lists.cs.columbia.edu
Cc: linux-kernel@vger.kernel.org, eauger@redhat.com,
oupton@google.com, Jonathan.Cameron@huawei.com,
vkuznets@redhat.com, will@kernel.org, shannon.zhaosl@gmail.com,
james.morse@arm.com, mark.rutland@arm.com, maz@kernel.org,
pbonzini@redhat.com, shan.gavin@gmail.com
Subject: [PATCH v6 01/18] KVM: arm64: Extend smccc_get_argx()
Date: Sun, 3 Apr 2022 23:38:54 +0800 [thread overview]
Message-ID: <20220403153911.12332-2-gshan@redhat.com> (raw)
In-Reply-To: <20220403153911.12332-1-gshan@redhat.com>
Currently, there are 3 inline functions to retrieve SMCCC arguments,
but the number of arguments is limited to 3. We need to retrieve
more SMCCC arguments when SDEI virtualization is supported.
This introduces smccc_get_arg(), which accepts @index to indicate
the SMCCC argument to be retrieved. Besides, smccc_get_function()
also calls into this newly introduced helper. Further more, we also
mechanically replace smccc_get_{arg1, arg2, arg3}() using the newly
introduced helper.
Signed-off-by: Gavin Shan <gshan@redhat.com>
---
arch/arm64/kvm/hypercalls.c | 4 ++--
arch/arm64/kvm/psci.c | 14 +++++++-------
arch/arm64/kvm/pvtime.c | 2 +-
arch/arm64/kvm/trng.c | 4 ++--
include/kvm/arm_hypercalls.h | 19 +++++--------------
5 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/arch/arm64/kvm/hypercalls.c b/arch/arm64/kvm/hypercalls.c
index 202b8c455724..8438fd79e3f0 100644
--- a/arch/arm64/kvm/hypercalls.c
+++ b/arch/arm64/kvm/hypercalls.c
@@ -34,7 +34,7 @@ static void kvm_ptp_get_time(struct kvm_vcpu *vcpu, u64 *val)
* (virtual or physical) with the first argument of the SMCCC
* call. In case the identifier is not supported, error out.
*/
- feature = smccc_get_arg1(vcpu);
+ feature = smccc_get_arg(vcpu, 1);
switch (feature) {
case KVM_PTP_VIRT_COUNTER:
cycles = systime_snapshot.cycles - vcpu_read_sys_reg(vcpu, CNTVOFF_EL2);
@@ -70,7 +70,7 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu)
val[0] = ARM_SMCCC_VERSION_1_1;
break;
case ARM_SMCCC_ARCH_FEATURES_FUNC_ID:
- feature = smccc_get_arg1(vcpu);
+ feature = smccc_get_arg(vcpu, 1);
switch (feature) {
case ARM_SMCCC_ARCH_WORKAROUND_1:
switch (arm64_get_spectre_v2_state()) {
diff --git a/arch/arm64/kvm/psci.c b/arch/arm64/kvm/psci.c
index 372da09a2fab..3aaa4921f3b3 100644
--- a/arch/arm64/kvm/psci.c
+++ b/arch/arm64/kvm/psci.c
@@ -71,7 +71,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
struct kvm_vcpu *vcpu = NULL;
unsigned long cpu_id;
- cpu_id = smccc_get_arg1(source_vcpu);
+ cpu_id = smccc_get_arg(source_vcpu, 1);
if (!kvm_psci_valid_affinity(source_vcpu, cpu_id))
return PSCI_RET_INVALID_PARAMS;
@@ -92,7 +92,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
reset_state = &vcpu->arch.reset_state;
- reset_state->pc = smccc_get_arg2(source_vcpu);
+ reset_state->pc = smccc_get_arg(source_vcpu, 2);
/* Propagate caller endianness */
reset_state->be = kvm_vcpu_is_be(source_vcpu);
@@ -101,7 +101,7 @@ static unsigned long kvm_psci_vcpu_on(struct kvm_vcpu *source_vcpu)
* NOTE: We always update r0 (or x0) because for PSCI v0.1
* the general purpose registers are undefined upon CPU_ON.
*/
- reset_state->r0 = smccc_get_arg3(source_vcpu);
+ reset_state->r0 = smccc_get_arg(source_vcpu, 3);
WRITE_ONCE(reset_state->reset, true);
kvm_make_request(KVM_REQ_VCPU_RESET, vcpu);
@@ -128,8 +128,8 @@ static unsigned long kvm_psci_vcpu_affinity_info(struct kvm_vcpu *vcpu)
struct kvm *kvm = vcpu->kvm;
struct kvm_vcpu *tmp;
- target_affinity = smccc_get_arg1(vcpu);
- lowest_affinity_level = smccc_get_arg2(vcpu);
+ target_affinity = smccc_get_arg(vcpu, 1);
+ lowest_affinity_level = smccc_get_arg(vcpu, 2);
if (!kvm_psci_valid_affinity(vcpu, target_affinity))
return PSCI_RET_INVALID_PARAMS;
@@ -326,7 +326,7 @@ static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor)
val = minor == 0 ? KVM_ARM_PSCI_1_0 : KVM_ARM_PSCI_1_1;
break;
case PSCI_1_0_FN_PSCI_FEATURES:
- arg = smccc_get_arg1(vcpu);
+ arg = smccc_get_arg(vcpu, 1);
val = kvm_psci_check_allowed_function(vcpu, arg);
if (val)
break;
@@ -364,7 +364,7 @@ static int kvm_psci_1_x_call(struct kvm_vcpu *vcpu, u32 minor)
fallthrough;
case PSCI_1_1_FN64_SYSTEM_RESET2:
if (minor >= 1) {
- arg = smccc_get_arg1(vcpu);
+ arg = smccc_get_arg(vcpu, 1);
if (arg <= PSCI_1_1_RESET_TYPE_SYSTEM_WARM_RESET ||
arg >= PSCI_1_1_RESET_TYPE_VENDOR_START) {
diff --git a/arch/arm64/kvm/pvtime.c b/arch/arm64/kvm/pvtime.c
index 78a09f7a6637..05e775fc9e8b 100644
--- a/arch/arm64/kvm/pvtime.c
+++ b/arch/arm64/kvm/pvtime.c
@@ -34,7 +34,7 @@ void kvm_update_stolen_time(struct kvm_vcpu *vcpu)
long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu)
{
- u32 feature = smccc_get_arg1(vcpu);
+ u32 feature = smccc_get_arg(vcpu, 1);
long val = SMCCC_RET_NOT_SUPPORTED;
switch (feature) {
diff --git a/arch/arm64/kvm/trng.c b/arch/arm64/kvm/trng.c
index 99bdd7103c9c..89911b724a26 100644
--- a/arch/arm64/kvm/trng.c
+++ b/arch/arm64/kvm/trng.c
@@ -24,7 +24,7 @@ static const uuid_t arm_smc_trng_uuid __aligned(4) = UUID_INIT(
static int kvm_trng_do_rnd(struct kvm_vcpu *vcpu, int size)
{
DECLARE_BITMAP(bits, TRNG_MAX_BITS64);
- u32 num_bits = smccc_get_arg1(vcpu);
+ u32 num_bits = smccc_get_arg(vcpu, 1);
int i;
if (num_bits > 3 * size) {
@@ -60,7 +60,7 @@ int kvm_trng_call(struct kvm_vcpu *vcpu)
val = ARM_SMCCC_TRNG_VERSION_1_0;
break;
case ARM_SMCCC_TRNG_FEATURES:
- switch (smccc_get_arg1(vcpu)) {
+ switch (smccc_get_arg(vcpu, 1)) {
case ARM_SMCCC_TRNG_VERSION:
case ARM_SMCCC_TRNG_FEATURES:
case ARM_SMCCC_TRNG_GET_UUID:
diff --git a/include/kvm/arm_hypercalls.h b/include/kvm/arm_hypercalls.h
index 0e2509d27910..723d2865c055 100644
--- a/include/kvm/arm_hypercalls.h
+++ b/include/kvm/arm_hypercalls.h
@@ -8,24 +8,15 @@
int kvm_hvc_call_handler(struct kvm_vcpu *vcpu);
-static inline u32 smccc_get_function(struct kvm_vcpu *vcpu)
-{
- return vcpu_get_reg(vcpu, 0);
-}
-
-static inline unsigned long smccc_get_arg1(struct kvm_vcpu *vcpu)
+static inline unsigned long smccc_get_arg(struct kvm_vcpu *vcpu,
+ unsigned char index)
{
- return vcpu_get_reg(vcpu, 1);
+ return vcpu_get_reg(vcpu, index);
}
-static inline unsigned long smccc_get_arg2(struct kvm_vcpu *vcpu)
-{
- return vcpu_get_reg(vcpu, 2);
-}
-
-static inline unsigned long smccc_get_arg3(struct kvm_vcpu *vcpu)
+static inline u32 smccc_get_function(struct kvm_vcpu *vcpu)
{
- return vcpu_get_reg(vcpu, 3);
+ return smccc_get_arg(vcpu, 0);
}
static inline void smccc_set_retval(struct kvm_vcpu *vcpu,
--
2.23.0
next prev parent reply other threads:[~2022-04-03 15:39 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-03 15:38 [PATCH v6 00/18] Support SDEI Virtualization Gavin Shan
2022-04-03 15:38 ` Gavin Shan [this message]
2022-04-03 15:38 ` [PATCH v6 02/18] KVM: arm64: Route hypercalls based on their owner Gavin Shan
2022-04-21 8:19 ` Oliver Upton
2022-04-22 12:20 ` Gavin Shan
2022-04-22 17:59 ` Oliver Upton
2022-04-23 12:48 ` Gavin Shan
2022-04-03 15:38 ` [PATCH v6 03/18] KVM: arm64: Add SDEI virtualization infrastructure Gavin Shan
2022-04-22 21:48 ` Oliver Upton
2022-04-23 14:18 ` Gavin Shan
2022-04-23 18:43 ` Oliver Upton
2022-04-24 3:00 ` Gavin Shan
2022-04-28 20:28 ` Oliver Upton
2022-04-30 11:38 ` Gavin Shan
2022-04-30 14:16 ` Oliver Upton
2022-05-02 2:35 ` Gavin Shan
2022-05-02 3:40 ` Oliver Upton
2022-05-02 7:25 ` Gavin Shan
2022-05-02 7:57 ` Oliver Upton
2022-05-02 8:23 ` Gavin Shan
2022-04-03 15:38 ` [PATCH v6 04/18] KVM: arm64: Support SDEI_EVENT_REGISTER hypercall Gavin Shan
2022-04-30 14:54 ` Oliver Upton
2022-05-02 2:55 ` Gavin Shan
2022-05-02 3:43 ` Oliver Upton
2022-05-02 7:28 ` Gavin Shan
2022-04-03 15:38 ` [PATCH v6 05/18] KVM: arm64: Support SDEI_EVENT_{ENABLE, DISABLE} Gavin Shan
2022-04-03 15:38 ` [PATCH v6 06/18] KVM: arm64: Support SDEI_EVENT_CONTEXT hypercall Gavin Shan
2022-04-30 15:03 ` Oliver Upton
2022-05-02 2:57 ` Gavin Shan
2022-04-03 15:39 ` [PATCH v6 07/18] KVM: arm64: Support SDEI_EVENT_UNREGISTER hypercall Gavin Shan
2022-04-03 15:39 ` [PATCH v6 08/18] KVM: arm64: Support SDEI_EVENT_STATUS hypercall Gavin Shan
2022-04-03 15:39 ` [PATCH v6 09/18] KVM: arm64: Support SDEI_EVENT_GET_INFO hypercall Gavin Shan
2022-04-03 15:39 ` [PATCH v6 10/18] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall Gavin Shan
2022-04-04 10:26 ` [PATCH] KVM: arm64: fix returnvar.cocci warnings kernel test robot
2022-04-04 10:54 ` Gavin Shan
2022-04-04 10:29 ` [PATCH v6 10/18] KVM: arm64: Support SDEI_PE_{MASK, UNMASK} hypercall kernel test robot
2022-04-03 15:39 ` [PATCH v6 11/18] KVM: arm64: Support SDEI_{PRIVATE, SHARED}_RESET Gavin Shan
2022-04-03 15:39 ` [PATCH v6 12/18] KVM: arm64: Support SDEI event injection, delivery Gavin Shan
2022-04-03 15:39 ` [PATCH v6 13/18] KVM: arm64: Support SDEI_EVENT_{COMPLETE,COMPLETE_AND_RESUME} hypercall Gavin Shan
2022-05-01 6:50 ` Oliver Upton
2022-05-02 6:19 ` Gavin Shan
2022-05-02 7:38 ` Oliver Upton
2022-05-02 7:51 ` Gavin Shan
2022-04-03 15:39 ` [PATCH v6 14/18] KVM: arm64: Support SDEI_EVENT_SIGNAL hypercall Gavin Shan
2022-04-30 21:32 ` Oliver Upton
2022-05-02 3:04 ` Gavin Shan
2022-04-03 15:39 ` [PATCH v6 15/18] KVM: arm64: Support SDEI_FEATURES hypercall Gavin Shan
2022-05-01 6:55 ` Oliver Upton
2022-05-02 3:05 ` Gavin Shan
2022-04-03 15:39 ` [PATCH v6 16/18] KVM: arm64: Support SDEI_VERSION hypercall Gavin Shan
2022-04-03 15:39 ` [PATCH v6 17/18] KVM: arm64: Expose SDEI capability Gavin Shan
2022-04-03 15:39 ` [PATCH v6 18/18] KVM: selftests: Add SDEI test case Gavin Shan
2022-04-03 15:47 ` [PATCH v6 00/18] Support SDEI Virtualization Gavin Shan
2022-04-04 6:09 ` Oliver Upton
2022-04-04 10:53 ` Gavin Shan
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=20220403153911.12332-2-gshan@redhat.com \
--to=gshan@redhat.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=eauger@redhat.com \
--cc=james.morse@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=shan.gavin@gmail.com \
--cc=shannon.zhaosl@gmail.com \
--cc=vkuznets@redhat.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®