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: <20190123174438.GJ19289@Konrads-MacBook-Pro.local>
Date:   Wed, 23 Jan 2019 12:44:41 -0500
From:   Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To:     KarimAllah Ahmed <karahmed@...zon.de>
Cc:     linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        pbonzini@...hat.com, rkrcmar@...hat.com
Subject: Re: [PATCH v5 05/13] X86/nVMX: handle_vmptrld: Use kvm_vcpu_map when
 copying VMCS12 from guest memory

On Wed, Jan 09, 2019 at 10:42:05AM +0100, KarimAllah Ahmed wrote:
> Use kvm_vcpu_map to the map the VMCS12 from guest memory because
> kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has
> a "struct page".
> 
> Signed-off-by: KarimAllah Ahmed <karahmed@...zon.de>

Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
> ---
> v4 -> v5:
> - Switch to the new guest mapping API instead of reading directly from
>   guest.
> - unmap with dirty flag
> v3 -> v4:
> - Return VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID on failure (jmattson@)
> v1 -> v2:
> - Massage commit message a bit.
> ---
>  arch/x86/kvm/vmx/nested.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
> index 536468a..5602b0c 100644
> --- a/arch/x86/kvm/vmx/nested.c
> +++ b/arch/x86/kvm/vmx/nested.c
> @@ -4521,11 +4521,10 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
>  		return 1;
>  
>  	if (vmx->nested.current_vmptr != vmptr) {
> +		struct kvm_host_map map;
>  		struct vmcs12 *new_vmcs12;
> -		struct page *page;
>  
> -		page = kvm_vcpu_gpa_to_page(vcpu, vmptr);
> -		if (is_error_page(page)) {
> +		if (kvm_vcpu_map(vcpu, gpa_to_gfn(vmptr), &map)) {
>  			/*
>  			 * Reads from an unbacked page return all 1s,
>  			 * which means that the 32 bits located at the
> @@ -4536,12 +4535,13 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
>  				VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
>  			return kvm_skip_emulated_instruction(vcpu);
>  		}
> -		new_vmcs12 = kmap(page);
> +
> +		new_vmcs12 = map.hva;
> +
>  		if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||
>  		    (new_vmcs12->hdr.shadow_vmcs &&
>  		     !nested_cpu_has_vmx_shadow_vmcs(vcpu))) {
> -			kunmap(page);
> -			kvm_release_page_clean(page);
> +			kvm_vcpu_unmap(&map, false);
>  			return nested_vmx_failValid(vcpu,
>  				VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
>  		}
> @@ -4553,8 +4553,7 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
>  		 * cached.
>  		 */
>  		memcpy(vmx->nested.cached_vmcs12, new_vmcs12, VMCS12_SIZE);
> -		kunmap(page);
> -		kvm_release_page_clean(page);
> +		kvm_vcpu_unmap(&map, false);
>  
>  		set_current_vmptr(vmx, vmptr);
>  	}
> -- 
> 2.7.4
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ