[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 08/33] target/ppc: Factor out the parsing in kvmppc_get
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 08/33] target/ppc: Factor out the parsing in kvmppc_get_cpu_characteristics() |
Date: |
Tue, 12 Jun 2018 16:44:38 +1000 |
From: Suraj Jitindar Singh <address@hidden>
Factor out the parsing of struct kvm_ppc_cpu_char in
kvmppc_get_cpu_characteristics() into a separate function for each cap
for simplicity.
Signed-off-by: Suraj Jitindar Singh <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
target/ppc/kvm.c | 59 ++++++++++++++++++++++++++++++++----------------
1 file changed, 39 insertions(+), 20 deletions(-)
diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c
index cbe13b18d1..2c0c34e125 100644
--- a/target/ppc/kvm.c
+++ b/target/ppc/kvm.c
@@ -2412,6 +2412,41 @@ bool kvmppc_has_cap_mmu_hash_v3(void)
return cap_mmu_hash_v3;
}
+static int parse_cap_ppc_safe_cache(struct kvm_ppc_cpu_char c)
+{
+ if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_L1D_FLUSH_PR) {
+ return 2;
+ } else if ((c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) &&
+ (c.character & c.character_mask
+ & (H_CPU_CHAR_L1D_FLUSH_ORI30 | H_CPU_CHAR_L1D_FLUSH_TRIG2))) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static int parse_cap_ppc_safe_bounds_check(struct kvm_ppc_cpu_char c)
+{
+ if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR) {
+ return 2;
+ } else if (c.character & c.character_mask & H_CPU_CHAR_SPEC_BAR_ORI31) {
+ return 1;
+ }
+
+ return 0;
+}
+
+static int parse_cap_ppc_safe_indirect_branch(struct kvm_ppc_cpu_char c)
+{
+ if (c.character & c.character_mask & H_CPU_CHAR_CACHE_COUNT_DIS) {
+ return SPAPR_CAP_FIXED_CCD;
+ } else if (c.character & c.character_mask & H_CPU_CHAR_BCCTRL_SERIALISED) {
+ return SPAPR_CAP_FIXED_IBS;
+ }
+
+ return 0;
+}
+
static void kvmppc_get_cpu_characteristics(KVMState *s)
{
struct kvm_ppc_cpu_char c;
@@ -2430,26 +2465,10 @@ static void kvmppc_get_cpu_characteristics(KVMState *s)
if (ret < 0) {
return;
}
- /* Parse and set cap_ppc_safe_cache */
- if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_L1D_FLUSH_PR) {
- cap_ppc_safe_cache = 2;
- } else if ((c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) &&
- (c.character & c.character_mask
- & (H_CPU_CHAR_L1D_FLUSH_ORI30 | H_CPU_CHAR_L1D_FLUSH_TRIG2))) {
- cap_ppc_safe_cache = 1;
- }
- /* Parse and set cap_ppc_safe_bounds_check */
- if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_BNDS_CHK_SPEC_BAR) {
- cap_ppc_safe_bounds_check = 2;
- } else if (c.character & c.character_mask & H_CPU_CHAR_SPEC_BAR_ORI31) {
- cap_ppc_safe_bounds_check = 1;
- }
- /* Parse and set cap_ppc_safe_indirect_branch */
- if (c.character & c.character_mask & H_CPU_CHAR_CACHE_COUNT_DIS) {
- cap_ppc_safe_indirect_branch = SPAPR_CAP_FIXED_CCD;
- } else if (c.character & c.character_mask & H_CPU_CHAR_BCCTRL_SERIALISED) {
- cap_ppc_safe_indirect_branch = SPAPR_CAP_FIXED_IBS;
- }
+
+ cap_ppc_safe_cache = parse_cap_ppc_safe_cache(c);
+ cap_ppc_safe_bounds_check = parse_cap_ppc_safe_bounds_check(c);
+ cap_ppc_safe_indirect_branch = parse_cap_ppc_safe_indirect_branch(c);
}
int kvmppc_get_cap_safe_cache(void)
--
2.17.1
- [Qemu-ppc] [PULL 02/33] macio: add trace-events to timer device, (continued)
- [Qemu-ppc] [PULL 02/33] macio: add trace-events to timer device, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 03/33] uninorth: remove token register from uninorth device, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 07/33] prep: fix keyboard for the 40p machine, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 11/33] osdep: powerpc64 align memory to allow 2MB radix THP page tables, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 10/33] spapr/vio: deprecate the "irq" property, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 13/33] MAINTAINERS: Add entries for the MOS6522 VIA device, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 09/33] target/ppc: Allow privileged access to SPR_PCR, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 04/33] hw/ppc/spapr_drc: Replace error_setg(&error_abort) by error_report() + abort(), David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 06/33] 40p: remove pci_allow_0_address = true from 40p machine class, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 05/33] target/ppc: Use proper logging function for possible guest errors, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 08/33] target/ppc: Factor out the parsing in kvmppc_get_cpu_characteristics(),
David Gibson <=
- [Qemu-ppc] [PULL 16/33] ppc: remove obsolete macio_init() definition from mac.h, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 15/33] ppc: remove obsolete pci_pmac_init() definitions from mac.h, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 17/33] ppc: add missing FW_CFG_PPC_NVRAM_FLAT definition, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 14/33] hw/misc/mos6522: Add trailing '\n' to qemu_log() calls, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 20/33] mos6522: move timer frequency initialisation to mos6522_reset, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 12/33] MAINTAINERS: Add an entry for the MacIO device headers, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 19/33] cuda: embed mos6522_cuda device directly rather than using QOM object link, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 22/33] target/ppc: extend eieio for POWER9, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 18/33] mos6522: fix vmstate_mos6522_timer version in vmstate_mos6522, David Gibson, 2018/06/12
- [Qemu-ppc] [PULL 29/33] spapr: handle pc-dimm unplug via hotplug handler chain, David Gibson, 2018/06/12