mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH] kvm: selftests: avoid type punning
Date: Mon, 20 May 2019 15:43:28 +0200	[thread overview]
Message-ID: <7dafd6d8-16ea-61b2-2f34-926af1af42cb@redhat.com> (raw)
In-Reply-To: <1558359538-14910-1-git-send-email-pbonzini@redhat.com>

On 20/05/2019 15.38, Paolo Bonzini wrote:
> Avoid warnings from -Wstrict-aliasing by using memcpy.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tools/testing/selftests/kvm/lib/ucall.c                        | 2 +-
>  tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/lib/ucall.c b/tools/testing/selftests/kvm/lib/ucall.c
> index a2ab38be2f47..b701a01cfcb6 100644
> --- a/tools/testing/selftests/kvm/lib/ucall.c
> +++ b/tools/testing/selftests/kvm/lib/ucall.c
> @@ -142,7 +142,7 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc)
>  		vm_vaddr_t gva;
>  		TEST_ASSERT(run->mmio.is_write && run->mmio.len == 8,
>  			    "Unexpected ucall exit mmio address access");
> -		gva = *(vm_vaddr_t *)run->mmio.data;
> +		memcpy(&gva, run->mmio.data, sizeof(gva));
>  		memcpy(uc, addr_gva2hva(vm, gva), sizeof(*uc));
>  	}
>  
> diff --git a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> index 61a2163cf9f1..9d62e2c7e024 100644
> --- a/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/vmx_set_nested_state_test.c
> @@ -75,7 +75,7 @@ void set_revision_id_for_vmcs12(struct kvm_nested_state *state,
>  				u32 vmcs12_revision)
>  {
>  	/* Set revision_id in vmcs12 to vmcs12_revision. */
> -	*(u32 *)(state->data) = vmcs12_revision;
> +	memcpy(state->data, &vmcs12_revision, sizeof(u32));
>  }
>  
>  void set_default_state(struct kvm_nested_state *state)
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>

      reply	other threads:[~2019-05-20 13:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-20 13:38 Paolo Bonzini
2019-05-20 13:43 ` Thomas Huth [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7dafd6d8-16ea-61b2-2f34-926af1af42cb@redhat.com \
    --to=thuth@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®