lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160412143443.GC6762@potion.brq.redhat.com>
Date:	Tue, 12 Apr 2016 16:34:43 +0200
From:	Radim Krčmář <rkrcmar@...hat.com>
To:	Suravee Suthikulpanit <Suravee.Suthikulpanit@....com>
Cc:	pbonzini@...hat.com, joro@...tes.org, bp@...en8.de,
	gleb@...nel.org, alex.williamson@...hat.com, kvm@...r.kernel.org,
	linux-kernel@...r.kernel.org, wei@...hat.com,
	sherry.hurwitz@....com
Subject: Re: [PART1 RFC v4 11/11] svm: Manage vcpu load/unload when enable
 AVIC

2016-04-07 03:20-0500, Suravee Suthikulpanit:
> From: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
> 
> When a vcpu is loaded/unloaded to a physical core, we need to update
> host physical APIC ID information in the Physical APIC-ID table
> accordingly.
> 
> Also, when vCPU is blocking/un-blocking (due to halt instruction),
> we need to make sure that the is-running bit in set accordingly in the
> physical APIC-ID table.
> 
> Signed-off-by: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
> ---

Thanks,

Reviewed-by: Radim Krčmář <rkrcmar@...hat.com>

> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
>  #define AVIC_LOGICAL_ID_ENTRY_GUEST_PHYSICAL_ID_MASK	(0xFF)
> @@ -1330,6 +1332,64 @@ free_avic:
> +/**
> + * This function is called during VCPU halt/unhalt.
> + */
> +static int avic_set_running(struct kvm_vcpu *vcpu, bool is_run)
> +{
> +	u64 entry;
> +	int h_physical_id = __default_cpu_present_to_apicid(vcpu->cpu);
> +	struct vcpu_svm *svm = to_svm(vcpu);
> +
> +	if (!svm_vcpu_avic_enabled(svm))
> +		return 0;
> +
> +	/* ID = 0xff (broadcast), ID > 0xff (reserved) */
> +	if (h_physical_id >= AVIC_PHYSICAL_ID_MAX)
> +		return -EINVAL;
> +
> +	entry = READ_ONCE(*(svm->avic_physical_id_cache));
> +	if (is_run)
> +		WARN_ON((entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK) != 0);
> +	else
> +		WARN_ON((entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK) == 0);

(We're pretty unlikely to hit this, so I'd give it just one line with:
 "is_run == !!(entry & AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK)")

> +
> +	entry &= ~AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
> +	if (is_run)
> +		entry |= AVIC_PHYSICAL_ID_ENTRY_IS_RUNNING_MASK;
> +	WRITE_ONCE(*(svm->avic_physical_id_cache), entry);
> +
> +	return 0;
> +}
> @@ -1395,6 +1455,11 @@ static struct kvm_vcpu *svm_create_vcpu(struct kvm *kvm, unsigned int id)
>  		}
>  	}
>  
> +	/* We initialize this flag to one to make sure that the is_running
> +	 * bit would be set the first time the vcpu is loaded.
> +	 */
> +	svm->avic_is_blocking = false;

(svm was zalloc'ed, so we know it to be false, but I guess that a bit of
 documentation doesn't hurt.)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ