kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
@ 2015-04-24 10:26 James Hogan
  2015-04-24 10:26 ` [PATCH 1/2] mips/kvm: Fix Big endian 32-bit register access James Hogan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: James Hogan @ 2015-04-24 10:26 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini
  Cc: James Hogan, Leon Alrae, Aurelien Jarno, kvm, qemu-stable

A couple of small fixes for accessing 32-bit KVM registers on big
endian, and to sign extend struct kvm_regs registers so as to work on
MIPS64 hosts.

James Hogan (2):
  mips/kvm: Fix Big endian 32-bit register access
  mips/kvm: Sign extend registers written to KVM

 target-mips/kvm.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: kvm@vger.kernel.org
Cc: qemu-stable@nongnu.org
-- 
2.0.5


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/2] mips/kvm: Fix Big endian 32-bit register access
  2015-04-24 10:26 [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
@ 2015-04-24 10:26 ` James Hogan
  2015-04-24 10:26 ` [PATCH 2/2] mips/kvm: Sign extend registers written to KVM James Hogan
  2015-07-08 15:03 ` [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
  2 siblings, 0 replies; 10+ messages in thread
From: James Hogan @ 2015-04-24 10:26 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini
  Cc: James Hogan, Leon Alrae, Aurelien Jarno, kvm, qemu-stable

Fix access to 32-bit registers on big endian targets. The pointer passed
to the kernel must be for the actual 32-bit value, not a temporary
64-bit value, otherwise on big endian systems the kernel will only
interpret the upper half.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: kvm@vger.kernel.org
Cc: qemu-stable@nongnu.org
---
 target-mips/kvm.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index 4d1f7ead8142..1597bbeac17a 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -240,10 +240,9 @@ int kvm_mips_set_ipi_interrupt(MIPSCPU *cpu, int irq, int level)
 static inline int kvm_mips_put_one_reg(CPUState *cs, uint64_t reg_id,
                                        int32_t *addr)
 {
-    uint64_t val64 = *addr;
     struct kvm_one_reg cp0reg = {
         .id = reg_id,
-        .addr = (uintptr_t)&val64
+        .addr = (uintptr_t)addr
     };
 
     return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, &cp0reg);
@@ -275,18 +274,12 @@ static inline int kvm_mips_put_one_reg64(CPUState *cs, uint64_t reg_id,
 static inline int kvm_mips_get_one_reg(CPUState *cs, uint64_t reg_id,
                                        int32_t *addr)
 {
-    int ret;
-    uint64_t val64 = 0;
     struct kvm_one_reg cp0reg = {
         .id = reg_id,
-        .addr = (uintptr_t)&val64
+        .addr = (uintptr_t)addr
     };
 
-    ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &cp0reg);
-    if (ret >= 0) {
-        *addr = val64;
-    }
-    return ret;
+    return kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, &cp0reg);
 }
 
 static inline int kvm_mips_get_one_ulreg(CPUState *cs, uint64 reg_id,
-- 
2.0.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] mips/kvm: Sign extend registers written to KVM
  2015-04-24 10:26 [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
  2015-04-24 10:26 ` [PATCH 1/2] mips/kvm: Fix Big endian 32-bit register access James Hogan
@ 2015-04-24 10:26 ` James Hogan
  2015-07-08 15:03 ` [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
  2 siblings, 0 replies; 10+ messages in thread
From: James Hogan @ 2015-04-24 10:26 UTC (permalink / raw)
  To: qemu-devel, Paolo Bonzini
  Cc: James Hogan, Leon Alrae, Aurelien Jarno, kvm, qemu-stable

In case we're running on a 64-bit host, be sure to sign extend the
general purpose registers and hi/lo/pc before writing them to KVM, so as
to take advantage of MIPS32/MIPS64 compatibility.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Leon Alrae <leon.alrae@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: kvm@vger.kernel.org
Cc: qemu-stable@nongnu.org
---
 target-mips/kvm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/target-mips/kvm.c b/target-mips/kvm.c
index 1597bbeac17a..d5388ca27568 100644
--- a/target-mips/kvm.c
+++ b/target-mips/kvm.c
@@ -633,12 +633,12 @@ int kvm_arch_put_registers(CPUState *cs, int level)
 
     /* Set the registers based on QEMU's view of things */
     for (i = 0; i < 32; i++) {
-        regs.gpr[i] = env->active_tc.gpr[i];
+        regs.gpr[i] = (int64_t)(target_long)env->active_tc.gpr[i];
     }
 
-    regs.hi = env->active_tc.HI[0];
-    regs.lo = env->active_tc.LO[0];
-    regs.pc = env->active_tc.PC;
+    regs.hi = (int64_t)(target_long)env->active_tc.HI[0];
+    regs.lo = (int64_t)(target_long)env->active_tc.LO[0];
+    regs.pc = (int64_t)(target_long)env->active_tc.PC;
 
     ret = kvm_vcpu_ioctl(cs, KVM_SET_REGS, &regs);
 
-- 
2.0.5


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-04-24 10:26 [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
  2015-04-24 10:26 ` [PATCH 1/2] mips/kvm: Fix Big endian 32-bit register access James Hogan
  2015-04-24 10:26 ` [PATCH 2/2] mips/kvm: Sign extend registers written to KVM James Hogan
@ 2015-07-08 15:03 ` James Hogan
  2015-07-08 15:22   ` Paolo Bonzini
  2 siblings, 1 reply; 10+ messages in thread
From: James Hogan @ 2015-07-08 15:03 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, Leon Alrae, Aurelien Jarno, kvm, qemu-stable

[-- Attachment #1: Type: text/plain, Size: 712 bytes --]

Hi Paolo,

On 24/04/15 11:26, James Hogan wrote:
> A couple of small fixes for accessing 32-bit KVM registers on big
> endian, and to sign extend struct kvm_regs registers so as to work on
> MIPS64 hosts.
> 
> James Hogan (2):
>   mips/kvm: Fix Big endian 32-bit register access
>   mips/kvm: Sign extend registers written to KVM

Any chance of applying these in time for v2.4?

Thanks
James

> 
>  target-mips/kvm.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Leon Alrae <leon.alrae@imgtec.com>
> Cc: Aurelien Jarno <aurelien@aurel32.net>
> Cc: kvm@vger.kernel.org
> Cc: qemu-stable@nongnu.org
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-08 15:03 ` [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
@ 2015-07-08 15:22   ` Paolo Bonzini
  2015-07-09  8:13     ` Leon Alrae
  0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2015-07-08 15:22 UTC (permalink / raw)
  To: James Hogan; +Cc: qemu-devel, Leon Alrae, Aurelien Jarno, kvm, qemu-stable

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256



On 08/07/2015 17:03, James Hogan wrote:
> Hi Paolo,
> 
> On 24/04/15 11:26, James Hogan wrote:
>> A couple of small fixes for accessing 32-bit KVM registers on
>> big endian, and to sign extend struct kvm_regs registers so as to
>> work on MIPS64 hosts.
>> 
>> James Hogan (2): mips/kvm: Fix Big endian 32-bit register access 
>> mips/kvm: Sign extend registers written to KVM
> 
> Any chance of applying these in time for v2.4?

I had assumed they'd go through Leon, but I can apply them for 2.4-rc1
as well.

Paolo
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJVnUA1AAoJEL/70l94x66D6C4H/1gZSesaDGwGgkSenPxook/u
h5GtvkgvyPqgKXrPaa9g+HW/TwrWMShwFa/w0+CX60DFZr+d7cgYhoiLjV/QeXVE
8stOGMUD77VVXgpmk6K8zl69AE6+LgaKsX3jv3VwqPvuQ8HeKY2jfypdl5fB2hFU
YdIG+yHJBhoDhO8pLHCGWpx0fP6VfRtoGPep7qzRB1iAQhzQEl9jMRBOJwPXy2Be
WDl7v/LFOJ0MkQ/ERPHwnr5QmrRFsVkOMF5ybaZbsBsDZZC385alRMijqp4pndHS
/AsRZ11++nIll26XFBfGFbMfb8NUXkxN8s1Y2/3/cYnlckNbRNWss3aoex6RJ+s=
=3qfd
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-08 15:22   ` Paolo Bonzini
@ 2015-07-09  8:13     ` Leon Alrae
  2015-07-09 13:49       ` Paolo Bonzini
  0 siblings, 1 reply; 10+ messages in thread
From: Leon Alrae @ 2015-07-09  8:13 UTC (permalink / raw)
  To: Paolo Bonzini, James Hogan; +Cc: qemu-devel, Aurelien Jarno, kvm, qemu-stable

On 08/07/2015 16:22, Paolo Bonzini wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
> 
> 
> 
> On 08/07/2015 17:03, James Hogan wrote:
>> Hi Paolo,
>>
>> On 24/04/15 11:26, James Hogan wrote:
>>> A couple of small fixes for accessing 32-bit KVM registers on
>>> big endian, and to sign extend struct kvm_regs registers so as to
>>> work on MIPS64 hosts.
>>>
>>> James Hogan (2): mips/kvm: Fix Big endian 32-bit register access 
>>> mips/kvm: Sign extend registers written to KVM
>>
>> Any chance of applying these in time for v2.4?
> 
> I had assumed they'd go through Leon, but I can apply them for 2.4-rc1
> as well.

I thought these changes would get applied via kvm queue since they touch
target-mips/kvm.c only. But if such target-specific kvm patches usually go via
target-* tree then I'm happy to pick them up.

Leon


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-09  8:13     ` Leon Alrae
@ 2015-07-09 13:49       ` Paolo Bonzini
  2015-07-09 13:58         ` [Qemu-devel] " Peter Maydell
  0 siblings, 1 reply; 10+ messages in thread
From: Paolo Bonzini @ 2015-07-09 13:49 UTC (permalink / raw)
  To: Leon Alrae, James Hogan; +Cc: qemu-devel, Aurelien Jarno, kvm, qemu-stable



On 09/07/2015 10:13, Leon Alrae wrote:
> On 08/07/2015 16:22, Paolo Bonzini wrote:
>> On 08/07/2015 17:03, James Hogan wrote:
>>> Hi Paolo,
>>>
>>> On 24/04/15 11:26, James Hogan wrote:
>>>> A couple of small fixes for accessing 32-bit KVM registers on
>>>> big endian, and to sign extend struct kvm_regs registers so as to
>>>> work on MIPS64 hosts.
>>>>
>>>> James Hogan (2): mips/kvm: Fix Big endian 32-bit register access 
>>>> mips/kvm: Sign extend registers written to KVM
>>>
>>> Any chance of applying these in time for v2.4?
>>
>> I had assumed they'd go through Leon, but I can apply them for 2.4-rc1
>> as well.
> 
> I thought these changes would get applied via kvm queue since they touch
> target-mips/kvm.c only. But if such target-specific kvm patches usually go via
> target-* tree then I'm happy to pick them up.

It's the same---they can go in through any tree.  In this case I've now
applied them and will send them out next week.

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-09 13:49       ` Paolo Bonzini
@ 2015-07-09 13:58         ` Peter Maydell
  2015-07-09 14:00           ` Peter Maydell
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2015-07-09 13:58 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Leon Alrae, James Hogan, qemu-stable, QEMU Developers,
	Aurelien Jarno, kvm-devel

On 9 July 2015 at 14:49, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 09/07/2015 10:13, Leon Alrae wrote:
>> On 08/07/2015 16:22, Paolo Bonzini wrote:
>>> On 08/07/2015 17:03, James Hogan wrote:
>>>> Hi Paolo,
>>>>
>>>> On 24/04/15 11:26, James Hogan wrote:
>>>>> A couple of small fixes for accessing 32-bit KVM registers on
>>>>> big endian, and to sign extend struct kvm_regs registers so as to
>>>>> work on MIPS64 hosts.
>>>>>
>>>>> James Hogan (2): mips/kvm: Fix Big endian 32-bit register access
>>>>> mips/kvm: Sign extend registers written to KVM
>>>>
>>>> Any chance of applying these in time for v2.4?
>>>
>>> I had assumed they'd go through Leon, but I can apply them for 2.4-rc1
>>> as well.
>>
>> I thought these changes would get applied via kvm queue since they touch
>> target-mips/kvm.c only. But if such target-specific kvm patches usually go via
>> target-* tree then I'm happy to pick them up.
>
> It's the same---they can go in through any tree.  In this case I've now
> applied them and will send them out next week.

I've actually just applied them to master as buildfixes :-)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-09 13:58         ` [Qemu-devel] " Peter Maydell
@ 2015-07-09 14:00           ` Peter Maydell
  2015-07-09 14:00             ` Paolo Bonzini
  0 siblings, 1 reply; 10+ messages in thread
From: Peter Maydell @ 2015-07-09 14:00 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Leon Alrae, James Hogan, qemu-stable, QEMU Developers,
	Aurelien Jarno, kvm-devel

On 9 July 2015 at 14:58, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 9 July 2015 at 14:49, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> It's the same---they can go in through any tree.  In this case I've now
>> applied them and will send them out next week.
>
> I've actually just applied them to master as buildfixes :-)

No, wait, I'm confusing this set with a different 2-patch
set of MIPS fixes. Paolo, can you go ahead and take them through
the kvm tree?

thanks
-- PMM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Qemu-devel] [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts
  2015-07-09 14:00           ` Peter Maydell
@ 2015-07-09 14:00             ` Paolo Bonzini
  0 siblings, 0 replies; 10+ messages in thread
From: Paolo Bonzini @ 2015-07-09 14:00 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Leon Alrae, James Hogan, qemu-stable, QEMU Developers,
	Aurelien Jarno, kvm-devel



On 09/07/2015 16:00, Peter Maydell wrote:
>> >
>> > I've actually just applied them to master as buildfixes :-)
> No, wait, I'm confusing this set with a different 2-patch
> set of MIPS fixes. Paolo, can you go ahead and take them through
> the kvm tree?

Sure, I had already queued them in fact.

Paolo

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-07-09 14:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-24 10:26 [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
2015-04-24 10:26 ` [PATCH 1/2] mips/kvm: Fix Big endian 32-bit register access James Hogan
2015-04-24 10:26 ` [PATCH 2/2] mips/kvm: Sign extend registers written to KVM James Hogan
2015-07-08 15:03 ` [PATCH 0/2] mips/kvm: Fixes for big endian & MIPS64 hosts James Hogan
2015-07-08 15:22   ` Paolo Bonzini
2015-07-09  8:13     ` Leon Alrae
2015-07-09 13:49       ` Paolo Bonzini
2015-07-09 13:58         ` [Qemu-devel] " Peter Maydell
2015-07-09 14:00           ` Peter Maydell
2015-07-09 14:00             ` Paolo Bonzini

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).