mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
target/ppc: Factor out the parsing in kvmppc_get_cpu_characteristics()
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 <sjitindarsingh@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
7cb00357c1
commit
8fea70440e
1 changed files with 39 additions and 20 deletions
|
@ -2412,6 +2412,41 @@ bool kvmppc_has_cap_mmu_hash_v3(void)
|
||||||
return cap_mmu_hash_v3;
|
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)
|
static void kvmppc_get_cpu_characteristics(KVMState *s)
|
||||||
{
|
{
|
||||||
struct kvm_ppc_cpu_char c;
|
struct kvm_ppc_cpu_char c;
|
||||||
|
@ -2430,26 +2465,10 @@ static void kvmppc_get_cpu_characteristics(KVMState *s)
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Parse and set cap_ppc_safe_cache */
|
|
||||||
if (~c.behaviour & c.behaviour_mask & H_CPU_BEHAV_L1D_FLUSH_PR) {
|
cap_ppc_safe_cache = parse_cap_ppc_safe_cache(c);
|
||||||
cap_ppc_safe_cache = 2;
|
cap_ppc_safe_bounds_check = parse_cap_ppc_safe_bounds_check(c);
|
||||||
} else if ((c.character & c.character_mask & H_CPU_CHAR_L1D_THREAD_PRIV) &&
|
cap_ppc_safe_indirect_branch = parse_cap_ppc_safe_indirect_branch(c);
|
||||||
(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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int kvmppc_get_cap_safe_cache(void)
|
int kvmppc_get_cap_safe_cache(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue