Skip to content

Commit d784cfe

Browse files
author
Marc Zyngier
committed
KVM: arm64: Simplify handling of full register invalid constraint
Now that we embed the RESx bits in the register description, it becomes easier to deal with registers that are simply not valid, as their existence is not satisfied by the configuration (SCTLR2_ELx without FEAT_SCTLR2, for example). Such registers essentially become RES0 for any bit that wasn't already advertised as RESx. Reviewed-by: Fuad Tabba <tabba@google.com> Tested-by: Fuad Tabba <tabba@google.com> Link: https://patch.msgid.link/20260202184329.2724080-17-maz@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent ab1f377 commit d784cfe

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

arch/arm64/kvm/config.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ static struct resx compute_reg_resx_bits(struct kvm *kvm,
13211321
unsigned long require,
13221322
unsigned long exclude)
13231323
{
1324-
struct resx resx, tmp;
1324+
struct resx resx;
13251325

13261326
resx = compute_resx_bits(kvm, r->bit_feat_map, r->bit_feat_map_sz,
13271327
require, exclude);
@@ -1331,11 +1331,14 @@ static struct resx compute_reg_resx_bits(struct kvm *kvm,
13311331
resx.res1 |= r->feat_map.masks->res1;
13321332
}
13331333

1334-
tmp = compute_resx_bits(kvm, &r->feat_map, 1, require, exclude);
1335-
1336-
resx.res0 |= tmp.res0;
1337-
resx.res0 |= ~reg_feat_map_bits(&r->feat_map);
1338-
resx.res1 |= tmp.res1;
1334+
/*
1335+
* If the register itself was not valid, all the non-RESx bits are
1336+
* now considered RES0 (this matches the behaviour of registers such
1337+
* as SCTLR2 and TCR2). Weed out any potential (though unlikely)
1338+
* overlap with RES1 bits coming from the previous computation.
1339+
*/
1340+
resx.res0 |= compute_resx_bits(kvm, &r->feat_map, 1, require, exclude).res0;
1341+
resx.res1 &= ~resx.res0;
13391342

13401343
return resx;
13411344
}

0 commit comments

Comments
 (0)