Skip to content

Commit 59a8814

Browse files
steffen-eidenfrankjaa
authored andcommitted
s390/uv: UV feature check utility
Introduces a function to check the existence of an UV feature. Refactor feature bit checks to use the new function. Signed-off-by: Steffen Eiden <seiden@linux.ibm.com> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Reviewed-by: Janosch Frank <frankja@linux.ibm.com> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> Reviewed-by: Michael Mueller <mimu@linux.ibm.com> Link: https://lore.kernel.org/r/20230815151415.379760-3-seiden@linux.ibm.com Message-Id: <20230815151415.379760-3-seiden@linux.ibm.com>
1 parent b1e4286 commit 59a8814

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

arch/s390/include/asm/uv.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,13 @@ struct uv_info {
397397

398398
extern struct uv_info uv_info;
399399

400+
static inline bool uv_has_feature(u8 feature_bit)
401+
{
402+
if (feature_bit >= sizeof(uv_info.uv_feature_indications) * 8)
403+
return false;
404+
return test_bit_inv(feature_bit, &uv_info.uv_feature_indications);
405+
}
406+
400407
#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
401408
extern int prot_virt_guest;
402409

arch/s390/kernel/uv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ static bool should_export_before_import(struct uv_cb_header *uvcb, struct mm_str
258258
* shared page from a different protected VM will automatically also
259259
* transfer its ownership.
260260
*/
261-
if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications))
261+
if (uv_has_feature(BIT_UV_FEAT_MISC))
262262
return false;
263263
if (uvcb->cmd == UVC_CMD_UNPIN_PAGE_SHARED)
264264
return false;

arch/s390/kvm/kvm-s390.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ static int kvm_s390_cpus_to_pv(struct kvm *kvm, u16 *rc, u16 *rrc)
24062406
struct kvm_vcpu *vcpu;
24072407

24082408
/* Disable the GISA if the ultravisor does not support AIV. */
2409-
if (!test_bit_inv(BIT_UV_FEAT_AIV, &uv_info.uv_feature_indications))
2409+
if (!uv_has_feature(BIT_UV_FEAT_AIV))
24102410
kvm_s390_gisa_disable(kvm);
24112411

24122412
kvm_for_each_vcpu(i, vcpu, kvm) {

arch/s390/mm/fault.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ void do_secure_storage_access(struct pt_regs *regs)
825825
* reliable without the misc UV feature so we need to check
826826
* for that as well.
827827
*/
828-
if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications) &&
828+
if (uv_has_feature(BIT_UV_FEAT_MISC) &&
829829
!test_bit_inv(61, &regs->int_parm_long)) {
830830
/*
831831
* When this happens, userspace did something that it

0 commit comments

Comments
 (0)