From: Roman Bolshakov <r.bolshakov@yadro.com>
To: Alexander Graf <agraf@csgraf.de>
Cc: Eduardo Habkost <ehabkost@redhat.com>, Asad Ali <asad@osaro.com>,
Richard Henderson <richard.henderson@linaro.org>,
qemu-devel@nongnu.org, Cameron Esfahani <dirty@apple.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] hvf: Fetch cr4 before evaluating CPUID(1)
Date: Tue, 9 Feb 2021 13:14:40 +0300 [thread overview]
Message-ID: <YCJgkHDFbWOeJxOf@SPB-NB-133.local> (raw)
In-Reply-To: <20210123004129.6364-1-agraf@csgraf.de>
On Sat, Jan 23, 2021 at 01:41:29AM +0100, Alexander Graf wrote:
> The CPUID function 1 has a bit called OSXSAVE which tells user space the
> status of the CR4.OSXSAVE bit. Our generic CPUID function injects that bit
> based on the status of CR4.
>
> With Hypervisor.framework, we do not synchronize full CPU state often enough
> for this function to see the CR4 update before guest user space asks for it.
>
> To be on the save side, let's just always synchronize it when we receive a
> CPUID(1) request. That way we can set the bit with real confidence.
>
> Reported-by: Asad Ali <asad@osaro.com>
> Signed-off-by: Alexander Graf <agraf@csgraf.de>
> ---
> target/i386/hvf/hvf.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c
> index 08b4adecd9..f660b829ac 100644
> --- a/target/i386/hvf/hvf.c
> +++ b/target/i386/hvf/hvf.c
> @@ -426,6 +426,10 @@ int hvf_vcpu_exec(CPUState *cpu)
> uint32_t rcx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RCX);
> uint32_t rdx = (uint32_t)rreg(cpu->hvf->fd, HV_X86_RDX);
>
> + if (rax == 1) {
> + /* CPUID1.ecx.OSXSAVE needs to know CR4 */
> + env->cr[4] = rvmcs(cpu->hvf->fd, VMCS_GUEST_CR4);
> + }
> cpu_x86_cpuid(env, rax, rcx, &rax, &rbx, &rcx, &rdx);
>
> wreg(cpu->hvf->fd, HV_X86_RAX, rax);
> --
> 2.24.3 (Apple Git-128)
>
The fix is based off hvf-arm patch series and doesn't build on
master branch because of "cpu->hvf->fd" has to be "cpu->hvf_fd".
I've corrected the issue and resolved conflicts with another patch in
hvf-queue. So, it's been queued.
Thanks,
Roman
prev parent reply other threads:[~2021-02-09 10:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-23 0:41 [PATCH] hvf: Fetch cr4 before evaluating CPUID(1) Alexander Graf
2021-02-09 10:14 ` Roman Bolshakov [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=YCJgkHDFbWOeJxOf@SPB-NB-133.local \
--to=r.bolshakov@yadro.com \
--cc=agraf@csgraf.de \
--cc=asad@osaro.com \
--cc=dirty@apple.com \
--cc=ehabkost@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).