Commit 59a88140 authored by Steffen Eiden's avatar Steffen Eiden Committed by Janosch Frank
Browse files

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: default avatarSteffen Eiden <seiden@linux.ibm.com>
Reviewed-by: default avatarClaudio Imbrenda <imbrenda@linux.ibm.com>
Reviewed-by: default avatarJanosch Frank <frankja@linux.ibm.com>
Signed-off-by: default avatarJanosch Frank <frankja@linux.ibm.com>
Reviewed-by: default avatarMichael 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>
parent b1e42861
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -397,6 +397,13 @@ struct uv_info {

extern struct uv_info uv_info;

static inline bool uv_has_feature(u8 feature_bit)
{
	if (feature_bit >= sizeof(uv_info.uv_feature_indications) * 8)
		return false;
	return test_bit_inv(feature_bit, &uv_info.uv_feature_indications);
}

#ifdef CONFIG_PROTECTED_VIRTUALIZATION_GUEST
extern int prot_virt_guest;

+1 −1
Original line number Diff line number Diff line
@@ -258,7 +258,7 @@ static bool should_export_before_import(struct uv_cb_header *uvcb, struct mm_str
	 * shared page from a different protected VM will automatically also
	 * transfer its ownership.
	 */
	if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications))
	if (uv_has_feature(BIT_UV_FEAT_MISC))
		return false;
	if (uvcb->cmd == UVC_CMD_UNPIN_PAGE_SHARED)
		return false;
+1 −1
Original line number Diff line number Diff line
@@ -2406,7 +2406,7 @@ static int kvm_s390_cpus_to_pv(struct kvm *kvm, u16 *rc, u16 *rrc)
	struct kvm_vcpu *vcpu;

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

	kvm_for_each_vcpu(i, vcpu, kvm) {
+1 −1
Original line number Diff line number Diff line
@@ -825,7 +825,7 @@ void do_secure_storage_access(struct pt_regs *regs)
	 * reliable without the misc UV feature so we need to check
	 * for that as well.
	 */
	if (test_bit_inv(BIT_UV_FEAT_MISC, &uv_info.uv_feature_indications) &&
	if (uv_has_feature(BIT_UV_FEAT_MISC) &&
	    !test_bit_inv(61, &regs->int_parm_long)) {
		/*
		 * When this happens, userspace did something that it