All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cedric Le Goater <clg@fr.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Paul Mackerras <paulus@samba.org>,
	kvm-ppc@vger.kernel.org,
	"kvm@vger.kernel.org mailing list" <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests
Date: Tue, 08 Oct 2013 16:10:59 +0000	[thread overview]
Message-ID: <52542E93.9040209@fr.ibm.com> (raw)
In-Reply-To: <723860B3-F578-4B4C-9364-7CE003E2D70D@suse.de>

On 10/08/2013 05:36 PM, Alexander Graf wrote:
> 
> On 08.10.2013, at 17:31, Cédric Le Goater <clg@fr.ibm.com> wrote:
> 
>> MMIO emulation reads the last instruction executed by the guest
>> and then emulates. If the guest is running in Little Endian mode,
>> the instruction needs to be byte-swapped before being emulated.
>>
>> This patch stores the last instruction in the endian order of the
>> host, primarily doing a byte-swap if needed. The common code
>> which fetches 'last_inst' uses a helper routine kvmppc_need_byteswap().
>> and the exit paths for the Book3S PV and HR guests use their own
>> version in assembly.
>>
>> Finally, the meaning of the 'is_bigendian' argument of the
>> routines kvmppc_handle_load() of kvmppc_handle_store() is
>> slightly changed to represent an eventual reverse operation. This
>> is used in conjunction with kvmppc_is_bigendian() to determine if
>> the instruction being emulated should be byte-swapped.
>>
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> ---
>>
>> Changes in v3:
>>
>> - moved kvmppc_need_byteswap() in kvmppc_ld32. It previously was in
>>   kvmppc_ld_inst(). (Alexander Graf)
>>
>> Changes in v2:
>>
>> - replaced rldicl. by andi. to test the MSR_LE bit in the guest
>>   exit paths. (Paul Mackerras)
>>
>> - moved the byte swapping logic to kvmppc_handle_load() and 
>>   kvmppc_handle_load() by changing the is_bigendian parameter
>>   meaning. (Paul Mackerras)
>>
>> arch/powerpc/include/asm/kvm_book3s.h   |    9 ++++++++-
>> arch/powerpc/include/asm/kvm_ppc.h      |   10 +++++-----
>> arch/powerpc/kvm/book3s_hv_rmhandlers.S |   11 +++++++++++
>> arch/powerpc/kvm/book3s_segment.S       |   10 ++++++++++
>> arch/powerpc/kvm/emulate.c              |    1 -
>> arch/powerpc/kvm/powerpc.c              |   16 ++++++++++++----
>> 6 files changed, 46 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
>> index 4ee6c66..9403042 100644
>> --- a/arch/powerpc/include/asm/kvm_book3s.h
>> +++ b/arch/powerpc/include/asm/kvm_book3s.h
>> @@ -283,7 +283,14 @@ static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu)
>> static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr,
>> 			      u32 *ptr, bool data)
>> {
>> -	return kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data);
>> +	int ret;
>> +
>> +	ret = kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data);
>> +
>> +	if (kvmppc_need_byteswap(vcpu))
>> +		*ptr = swab32(*ptr);
>> +
>> +	return ret;
>> }
>>
>> static inline int kvmppc_ld_inst(struct kvm_vcpu *vcpu, ulong *eaddr,
> 
> ... at which point this helper is pretty useless ;).

ok. This sounds like a request for a v4 ... :)

C.




WARNING: multiple messages have this Message-ID (diff)
From: Cedric Le Goater <clg@fr.ibm.com>
To: Alexander Graf <agraf@suse.de>
Cc: Paul Mackerras <paulus@samba.org>,
	kvm-ppc@vger.kernel.org,
	"kvm@vger.kernel.org mailing list" <kvm@vger.kernel.org>
Subject: Re: [PATCH v3 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests
Date: Tue, 08 Oct 2013 18:10:59 +0200	[thread overview]
Message-ID: <52542E93.9040209@fr.ibm.com> (raw)
In-Reply-To: <723860B3-F578-4B4C-9364-7CE003E2D70D@suse.de>

On 10/08/2013 05:36 PM, Alexander Graf wrote:
> 
> On 08.10.2013, at 17:31, Cédric Le Goater <clg@fr.ibm.com> wrote:
> 
>> MMIO emulation reads the last instruction executed by the guest
>> and then emulates. If the guest is running in Little Endian mode,
>> the instruction needs to be byte-swapped before being emulated.
>>
>> This patch stores the last instruction in the endian order of the
>> host, primarily doing a byte-swap if needed. The common code
>> which fetches 'last_inst' uses a helper routine kvmppc_need_byteswap().
>> and the exit paths for the Book3S PV and HR guests use their own
>> version in assembly.
>>
>> Finally, the meaning of the 'is_bigendian' argument of the
>> routines kvmppc_handle_load() of kvmppc_handle_store() is
>> slightly changed to represent an eventual reverse operation. This
>> is used in conjunction with kvmppc_is_bigendian() to determine if
>> the instruction being emulated should be byte-swapped.
>>
>> Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
>> ---
>>
>> Changes in v3:
>>
>> - moved kvmppc_need_byteswap() in kvmppc_ld32. It previously was in
>>   kvmppc_ld_inst(). (Alexander Graf)
>>
>> Changes in v2:
>>
>> - replaced rldicl. by andi. to test the MSR_LE bit in the guest
>>   exit paths. (Paul Mackerras)
>>
>> - moved the byte swapping logic to kvmppc_handle_load() and 
>>   kvmppc_handle_load() by changing the is_bigendian parameter
>>   meaning. (Paul Mackerras)
>>
>> arch/powerpc/include/asm/kvm_book3s.h   |    9 ++++++++-
>> arch/powerpc/include/asm/kvm_ppc.h      |   10 +++++-----
>> arch/powerpc/kvm/book3s_hv_rmhandlers.S |   11 +++++++++++
>> arch/powerpc/kvm/book3s_segment.S       |   10 ++++++++++
>> arch/powerpc/kvm/emulate.c              |    1 -
>> arch/powerpc/kvm/powerpc.c              |   16 ++++++++++++----
>> 6 files changed, 46 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
>> index 4ee6c66..9403042 100644
>> --- a/arch/powerpc/include/asm/kvm_book3s.h
>> +++ b/arch/powerpc/include/asm/kvm_book3s.h
>> @@ -283,7 +283,14 @@ static inline bool kvmppc_is_bigendian(struct kvm_vcpu *vcpu)
>> static inline int kvmppc_ld32(struct kvm_vcpu *vcpu, ulong *eaddr,
>> 			      u32 *ptr, bool data)
>> {
>> -	return kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data);
>> +	int ret;
>> +
>> +	ret = kvmppc_ld(vcpu, eaddr, sizeof(u32), ptr, data);
>> +
>> +	if (kvmppc_need_byteswap(vcpu))
>> +		*ptr = swab32(*ptr);
>> +
>> +	return ret;
>> }
>>
>> static inline int kvmppc_ld_inst(struct kvm_vcpu *vcpu, ulong *eaddr,
> 
> ... at which point this helper is pretty useless ;).

ok. This sounds like a request for a v4 ... :)

C.




  reply	other threads:[~2013-10-08 16:10 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08 14:12 [PATCH v2 0/3] KVM: PPC: Book3S: MMIO support for Little Endian guests Cédric Le Goater
2013-10-08 14:12 ` Cédric Le Goater
2013-10-08 14:12 ` [PATCH v2 1/3] KVM: PPC: Book3S: add helper routine to load guest instructions Cédric Le Goater
2013-10-08 14:12   ` Cédric Le Goater
2013-10-08 14:12 ` [PATCH v2 2/3] KVM: PPC: Book3S: add helper routines to detect endian Cédric Le Goater
2013-10-08 14:12   ` Cédric Le Goater
2013-10-08 14:12 ` [PATCH v2 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests Cédric Le Goater
2013-10-08 14:12   ` Cédric Le Goater
2013-10-08 14:25   ` Alexander Graf
2013-10-08 14:25     ` Alexander Graf
2013-10-08 15:07     ` Cedric Le Goater
2013-10-08 15:07       ` Cedric Le Goater
2013-10-08 15:31       ` [PATCH v3 " Cédric Le Goater
2013-10-08 15:31         ` Cédric Le Goater
2013-10-08 15:36         ` Alexander Graf
2013-10-08 15:36           ` Alexander Graf
2013-10-08 16:10           ` Cedric Le Goater [this message]
2013-10-08 16:10             ` Cedric Le Goater
2013-10-08 16:43             ` [PATCH v4 0/3] KVM: PPC: Book3S: MMIO support for Little Endian guests Cédric Le Goater
2013-10-08 16:43               ` Cédric Le Goater
2013-10-08 16:43               ` [PATCH v4 1/3] KVM: PPC: Book3S: add helper routine to load guest instructions Cédric Le Goater
2013-10-08 16:43                 ` Cédric Le Goater
2013-10-08 16:43               ` [PATCH v4 2/3] KVM: PPC: Book3S: add helper routines to detect endian order Cédric Le Goater
2013-10-08 16:43                 ` Cédric Le Goater
2013-10-08 16:43               ` [PATCH v4 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests Cédric Le Goater
2013-10-08 16:43                 ` Cédric Le Goater
2013-10-08 23:31     ` [PATCH v2 " Paul Mackerras
2013-10-08 23:31       ` Paul Mackerras
2013-10-08 23:46       ` Alexander Graf
2013-10-08 23:46         ` Alexander Graf
2013-10-09  5:59         ` Paul Mackerras
2013-10-09  5:59           ` Paul Mackerras
2013-10-09  8:29           ` Alexander Graf
2013-10-09  8:29             ` Alexander Graf
2013-10-09  8:42             ` Cedric Le Goater
2013-10-09  8:42               ` Cedric Le Goater
2013-10-10 10:16             ` Paul Mackerras
2013-10-10 10:16               ` Paul Mackerras
2013-11-04 11:44               ` Alexander Graf
2013-11-04 11:44                 ` Alexander Graf
2013-11-05 12:28                 ` Cedric Le Goater
2013-11-05 12:28                   ` Cedric Le Goater
2013-11-05 13:01                   ` Alexander Graf
2013-11-05 13:01                     ` Alexander Graf
2013-11-05 17:22                     ` [PATCH v5 0/6] KVM: PPC: Book3S: MMIO support for Little Endian guests Cédric Le Goater
2013-11-05 17:22                       ` Cédric Le Goater
2013-11-05 17:22                       ` [PATCH v5 1/6] KVM: PPC: Book3S: add helper routine to load guest instructions Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2013-11-05 17:22                       ` [PATCH v5 2/6] KVM: PPC: Book3S: add helper routines to detect endian Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2014-01-02 20:05                         ` Alexander Graf
2014-01-02 20:05                           ` Alexander Graf
2014-01-08 17:22                           ` Cedric Le Goater
2014-01-08 17:22                             ` Cedric Le Goater
2013-11-05 17:22                       ` [PATCH v5 3/6] KVM: PPC: Book3S: MMIO emulation support for little endian guests Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2014-01-02 20:22                         ` Alexander Graf
2014-01-02 20:22                           ` Alexander Graf
2014-01-08 17:23                           ` Cedric Le Goater
2014-01-08 17:23                             ` Cedric Le Goater
2014-01-08 17:34                             ` Alexander Graf
2014-01-08 17:34                               ` Alexander Graf
2014-01-08 17:40                               ` Cedric Le Goater
2014-01-08 17:40                                 ` Cedric Le Goater
2014-01-08 17:35                             ` [PATCH v6] " Cédric Le Goater
2014-01-08 17:35                               ` Cédric Le Goater
2014-01-09 10:02                             ` [PATCH v7] " Cédric Le Goater
2014-01-09 10:02                               ` Cédric Le Goater
2014-01-09 10:17                               ` Alexander Graf
2014-01-09 10:17                                 ` Alexander Graf
2014-01-09 10:33                                 ` Cedric Le Goater
2014-01-09 10:33                                   ` Cedric Le Goater
2014-01-09 10:51                                   ` [PATCH v8] " Cédric Le Goater
2014-01-09 10:51                                     ` Cédric Le Goater
2014-01-09 10:55                                     ` Alexander Graf
2014-01-09 10:55                                       ` Alexander Graf
2013-11-05 17:22                       ` [PATCH v5 4/6] KVM: PPC: Book3S: modify kvmppc_need_byteswap() for little endian host Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2013-11-08 14:36                         ` [PATCH v5.1 " Cedric Le Goater
2013-11-08 14:36                           ` Cedric Le Goater
2014-01-02 20:28                           ` Alexander Graf
2014-01-02 20:28                             ` Alexander Graf
2014-01-02 20:25                         ` [PATCH v5 " Alexander Graf
2014-01-02 20:25                           ` Alexander Graf
2013-11-05 17:22                       ` [PATCH v5 5/6] powerpc: add Split Little Endian bit to MSR Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2013-11-05 17:22                       ` [PATCH v5 6/6] KVM: PPC: Book3S: modify byte loading when guest uses Split Little Endian Cédric Le Goater
2013-11-05 17:22                         ` Cédric Le Goater
2014-01-02 20:26                         ` Alexander Graf
2014-01-02 20:26                           ` Alexander Graf
2013-11-06  5:55                     ` [PATCH v2 3/3] KVM: PPC: Book3S: MMIO emulation support for little endian guests Paul Mackerras
2013-11-06  5:55                       ` Paul Mackerras
2013-11-08 14:29                       ` Cedric Le Goater
2013-11-08 14:29                         ` Cedric Le Goater

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=52542E93.9040209@fr.ibm.com \
    --to=clg@fr.ibm.com \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=paulus@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.