From: Steven Price <steven.price@arm.com>
To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org
Cc: Marc Zyngier <marc.zyngier@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Steven Price <steven.price@arm.com>
Subject: [RFC PATCH v2 04/12] arm/arm64: Make use of the SMCCC 1.1 wrapper
Date: Wed, 12 Dec 2018 15:02:18 +0000 [thread overview]
Message-ID: <20181212150226.38051-5-steven.price@arm.com> (raw)
In-Reply-To: <20181212150226.38051-1-steven.price@arm.com>
Rather than directly choosing which function to use based on
psci_ops.conduit, use the new arm_smccc_1_1 wrapper instead.
In some cases we still need to do some operations based on the
conduit, but the code duplication is removed.
Signed-off-by: Steven Price <steven.price@arm.com>
---
arch/arm/mm/proc-v7-bugs.c | 46 +++++++++++++++------------------
arch/arm64/kernel/cpu_errata.c | 47 +++++++++-------------------------
2 files changed, 32 insertions(+), 61 deletions(-)
diff --git a/arch/arm/mm/proc-v7-bugs.c b/arch/arm/mm/proc-v7-bugs.c
index 5544b82a2e7a..a9c7474d3e39 100644
--- a/arch/arm/mm/proc-v7-bugs.c
+++ b/arch/arm/mm/proc-v7-bugs.c
@@ -78,39 +78,33 @@ static void cpu_v7_spectre_init(void)
case ARM_CPU_PART_CORTEX_A57:
case ARM_CPU_PART_CORTEX_A72: {
struct arm_smccc_res res;
+ int conduit;
if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
break;
- switch (psci_ops.conduit) {
- case PSCI_CONDUIT_HVC:
- arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 != 0)
- break;
+ conduit = arm_smccc_1_1_call(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+ ARM_SMCCC_ARCH_WORKAROUND_1, &res);
+
+ if ((int)res.a0 == 0) {
if (processor.switch_mm != cpu_v7_hvc_switch_mm && cpu)
goto bl_error;
- per_cpu(harden_branch_predictor_fn, cpu) =
- call_hvc_arch_workaround_1;
- processor.switch_mm = cpu_v7_hvc_switch_mm;
- spectre_v2_method = "hypervisor";
- break;
-
- case PSCI_CONDUIT_SMC:
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 != 0)
+ switch (conduit) {
+ case PSCI_CONDUIT_HVC:
+ per_cpu(harden_branch_predictor_fn, cpu) =
+ call_hvc_arch_workaround_1;
+ processor.switch_mm = cpu_v7_hvc_switch_mm;
+ spectre_v2_method = "hypervisor";
break;
- if (processor.switch_mm != cpu_v7_smc_switch_mm && cpu)
- goto bl_error;
- per_cpu(harden_branch_predictor_fn, cpu) =
- call_smc_arch_workaround_1;
- processor.switch_mm = cpu_v7_smc_switch_mm;
- spectre_v2_method = "firmware";
- break;
-
- default:
- break;
+ case PSCI_CONDUIT_SMC:
+ per_cpu(harden_branch_predictor_fn, cpu) =
+ call_smc_arch_workaround_1;
+ processor.switch_mm = cpu_v7_smc_switch_mm;
+ spectre_v2_method = "firmware";
+ break;
+ default:
+ break;
+ }
}
}
#endif
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index a509e35132d2..fee09ee52ec8 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -234,12 +234,14 @@ enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
return;
+ arm_smccc_1_1_call(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+ ARM_SMCCC_ARCH_WORKAROUND_1, &res);
+
+ if ((int)res.a0 < 0)
+ return;
+
switch (psci_ops.conduit) {
case PSCI_CONDUIT_HVC:
- arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 < 0)
- return;
cb = call_hvc_arch_workaround_1;
/* This is a guest, no need to patch KVM vectors */
smccc_start = NULL;
@@ -247,10 +249,6 @@ enable_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
break;
case PSCI_CONDUIT_SMC:
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_1, &res);
- if ((int)res.a0 < 0)
- return;
cb = call_smc_arch_workaround_1;
smccc_start = __smccc_workaround_1_smc_start;
smccc_end = __smccc_workaround_1_smc_end;
@@ -343,6 +341,8 @@ void __init arm64_enable_wa2_handling(struct alt_instr *alt,
void arm64_set_ssbd_mitigation(bool state)
{
+ int conduit;
+
if (this_cpu_has_cap(ARM64_SSBS)) {
if (state)
asm volatile(SET_PSTATE_SSBS(0));
@@ -351,19 +351,9 @@ void arm64_set_ssbd_mitigation(bool state)
return;
}
- switch (psci_ops.conduit) {
- case PSCI_CONDUIT_HVC:
- arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
- break;
-
- case PSCI_CONDUIT_SMC:
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
- break;
+ conduit = arm_smccc_1_1_call(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
- default:
- WARN_ON_ONCE(1);
- break;
- }
+ WARN_ON_ONCE(conduit == PSCI_CONDUIT_NONE);
}
static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
@@ -385,21 +375,8 @@ static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
return false;
}
- switch (psci_ops.conduit) {
- case PSCI_CONDUIT_HVC:
- arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_2, &res);
- break;
-
- case PSCI_CONDUIT_SMC:
- arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
- ARM_SMCCC_ARCH_WORKAROUND_2, &res);
- break;
-
- default:
- ssbd_state = ARM64_SSBD_UNKNOWN;
- return false;
- }
+ arm_smccc_1_1_call(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
+ ARM_SMCCC_ARCH_WORKAROUND_2, &res);
val = (s32)res.a0;
--
2.19.2
next prev parent reply other threads:[~2018-12-12 15:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 15:02 [RFC PATCH v2 00/12] arm64: Paravirtualized time support Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 01/12] KVM: arm64: Document PV-time interface Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 02/12] KVM: arm/arm64: Factor out hypercall handling from PSCI code Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 03/12] arm/arm64: Provide a wrapper for SMCCC 1.1 calls Steven Price
2018-12-12 15:02 ` Steven Price [this message]
2018-12-12 15:02 ` [RFC PATCH v2 05/12] KVM: arm64: Implement PV_FEATURES call Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 06/12] KVM: arm64: Support stolen time reporting via shared structure Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 07/12] arm64: Retrieve stolen time as paravirtualized guest Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 08/12] KVM: Allow kvm_device_ops to be const Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 09/12] KVM: arm64: Provide a PV_TIME device to user space Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 10/12] KVM: arm64: Support Live Physical Time reporting Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 11/12] clocksource: arm_arch_timer: Use paravirtualized LPT Steven Price
2018-12-12 15:02 ` [RFC PATCH v2 12/12] KVM: arm64: Export LPT using PV_TIME device Steven Price
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=20181212150226.38051-5-steven.price@arm.com \
--to=steven.price@arm.com \
--cc=catalin.marinas@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=marc.zyngier@arm.com \
--cc=will.deacon@arm.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: 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;
as well as URLs for NNTP newsgroup(s).