Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <ddaney.cavm@gmail.com>
To: Avi Kivity <avi@redhat.com>, Sanjay Lal <sanjayl@kymasys.com>
Cc: kvm@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH 02/20] KVM/MIPS32: Arch specific KVM data structures.
Date: Thu, 01 Nov 2012 09:51:10 -0700	[thread overview]
Message-ID: <5092A87E.60907@gmail.com> (raw)
In-Reply-To: <50928F87.4060309@redhat.com>

On 11/01/2012 08:04 AM, Avi Kivity wrote:
> On 10/31/2012 05:18 PM, Sanjay Lal wrote:
>>
>> Signed-off-by: Sanjay Lal <sanjayl@kymasys.com>
>> ---
>>   arch/mips/include/asm/kvm.h      |  58 ++++
>>   arch/mips/include/asm/kvm_host.h | 672 +++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 730 insertions(+)
>>   create mode 100644 arch/mips/include/asm/kvm.h
>>   create mode 100644 arch/mips/include/asm/kvm_host.h
>>
>> diff --git a/arch/mips/include/asm/kvm.h b/arch/mips/include/asm/kvm.h
>> new file mode 100644
>> index 0000000..39bb715
>> --- /dev/null
>> +++ b/arch/mips/include/asm/kvm.h
>> @@ -0,0 +1,58 @@
>> +/*
>> +* This file is subject to the terms and conditions of the GNU General Public
>> +* License.  See the file "COPYING" in the main directory of this archive
>> +* for more details.
>> +*
>> +*
>> +* Copyright (C) 2012  MIPS Technologies, Inc.  All rights reserved.
>> +* Authors: Sanjay Lal <sanjayl@kymasys.com>
>> +*/
>> +
>> +
>> +#ifndef __LINUX_KVM_MIPS_H
>> +#define __LINUX_KVM_MIPS_H
>> +
>> +#include <linux/types.h>
>> +
>> +#define __KVM_MIPS
>> +
>> +#define N_MIPS_COPROC_REGS      32
>> +#define N_MIPS_COPROC_SEL   	8
>> +
>> +/* for KVM_GET_REGS and KVM_SET_REGS */
>> +struct kvm_regs {
>> +    __u32 gprs[32];
>> +    __u32 hi;
>> +    __u32 lo;
>> +    __u32 pc;
>> +
>> +    ulong cp0reg[N_MIPS_COPROC_REGS][N_MIPS_COPROC_SEL];
>> +};
>
> ulong changes size in 64-bit archs, requiring compat translations when
> issuing 32-bit syscalls on a 64-bit kernel.  I don't know MIPS enough to
> know whether that's a useful scenario.

For a 32-bit machine all the registers are 32-bits wide.

For a 64-bit machine, they are ... yes 64-bits wide.

Since this entire structure seems to be useless for a 64-bit 
implementation just use __u32 for everything.

This does beg the question though, how will you handle 64-bit machines?

Why not name the entire structure something like struct kvm_regs_mips32? 
  Then for the 64-bit implementation use struct kvm_regs_mips64.

I haven't studied it enough to know if you can do this.  if it needs to 
be called exactly 'struct kvm_regs', then you have to make everything 
__u64 and only populate the lower halves of the fields for mips32. 
Watch out for endian issues in this case.

David Daney

  reply	other threads:[~2012-11-01 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-31 15:18 [PATCH 02/20] KVM/MIPS32: Arch specific KVM data structures Sanjay Lal
2012-11-01 15:04 ` Avi Kivity
2012-11-01 16:51   ` David Daney [this message]
2012-11-02 17:11   ` Sanjay Lal
2012-11-04 19:04     ` Avi Kivity

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=5092A87E.60907@gmail.com \
    --to=ddaney.cavm@gmail.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=sanjayl@kymasys.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