diff mbox series

KVM: SVM: Fix offset computation bug in __sev_dbg_decrypt().

Message ID 20201110224205.29444-1-Ashish.Kalra@amd.com (mailing list archive)
State New, archived
Headers show
Series KVM: SVM: Fix offset computation bug in __sev_dbg_decrypt(). | expand

Commit Message

Kalra, Ashish Nov. 10, 2020, 10:42 p.m. UTC
From: Ashish Kalra <ashish.kalra@amd.com>

Fix offset computation in __sev_dbg_decrypt() to include the
source paddr before it is rounded down to be aligned to 16 bytes
as required by SEV API. This fixes incorrect guest memory dumps
observed when using qemu monitor.

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 arch/x86/kvm/svm/sev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Bonzini Nov. 16, 2020, 6:59 p.m. UTC | #1
On 10/11/20 23:42, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
> 
> Fix offset computation in __sev_dbg_decrypt() to include the
> source paddr before it is rounded down to be aligned to 16 bytes
> as required by SEV API. This fixes incorrect guest memory dumps
> observed when using qemu monitor.
> 
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> ---
>   arch/x86/kvm/svm/sev.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index c0b14106258a..566f4d18185b 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -642,8 +642,8 @@ static int __sev_dbg_decrypt(struct kvm *kvm, unsigned long src_paddr,
>   	 * Its safe to read more than we are asked, caller should ensure that
>   	 * destination has enough space.
>   	 */
> -	src_paddr = round_down(src_paddr, 16);
>   	offset = src_paddr & 15;
> +	src_paddr = round_down(src_paddr, 16);
>   	sz = round_up(sz + offset, 16);
>   
>   	return __sev_issue_dbg_cmd(kvm, src_paddr, dst_paddr, sz, err, false);
> 

I just missed it.  Queued now, thanks.

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index c0b14106258a..566f4d18185b 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -642,8 +642,8 @@  static int __sev_dbg_decrypt(struct kvm *kvm, unsigned long src_paddr,
 	 * Its safe to read more than we are asked, caller should ensure that
 	 * destination has enough space.
 	 */
-	src_paddr = round_down(src_paddr, 16);
 	offset = src_paddr & 15;
+	src_paddr = round_down(src_paddr, 16);
 	sz = round_up(sz + offset, 16);
 
 	return __sev_issue_dbg_cmd(kvm, src_paddr, dst_paddr, sz, err, false);