qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@linux.vnet.ibm.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Anthony Liguori <aliguori@us.ibm.com>,
	Avi Kivity <avi@redhat.com>,
	qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Huang Ying <ying.huang@intel.com>
Subject: [Qemu-devel] Re: [PATCH 07/10] Add RAM -> physical addr mapping in MCE simulation
Date: Wed, 20 Oct 2010 14:56:32 -0500	[thread overview]
Message-ID: <4CBF4970.5040504@linux.vnet.ibm.com> (raw)
In-Reply-To: <9867fba99ce6108dcc6684d707aa30681b46f5f8.1287596626.git.mtosatti@redhat.com>

On 10/20/2010 12:43 PM, Marcelo Tosatti wrote:
> From: Huang Ying<ying.huang@intel.com>
>
> In QEMU-KVM, physical address != RAM address. While MCE simulation
> needs physical address instead of RAM address. So
> kvm_physical_memory_addr_from_ram() is implemented to do the
> conversion, and it is invoked before being filled in the IA32_MCi_ADDR
> MSR.
>
> Reported-by: Dean Nelson<dnelson@redhat.com>
> Signed-off-by: Huang Ying<ying.huang@intel.com>
> Signed-off-by: Marcelo Tosatti<mtosatti@redhat.com>
> Signed-off-by: Avi Kivity<avi@redhat.com>
> ---
>   kvm-all.c |   18 ++++++++++++++++++
>   kvm.h     |    6 ++++++
>   2 files changed, 24 insertions(+), 0 deletions(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 1cc696f..37b99c7 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -137,6 +137,24 @@ static KVMSlot *kvm_lookup_overlapping_slot(KVMState *s,
>       return found;
>   }
>
> +int kvm_physical_memory_addr_from_ram(KVMState *s, ram_addr_t ram_addr,
> +                                      target_phys_addr_t *phys_addr)
> +{
> +    int i;
> +
> +    for (i = 0; i<  ARRAY_SIZE(s->slots); i++) {
> +        KVMSlot *mem =&s->slots[i];
> +
> +        if (ram_addr>= mem->phys_offset&&
> +            ram_addr<  mem->phys_offset + mem->memory_size) {
> +            *phys_addr = mem->start_addr + (ram_addr - mem->phys_offset);
> +            return 1;
> +        }
> +    }
>    

This is bogus.

There isn't one mapping from ram_addr_t to target_phys_addr_t.  There 
may be many because or RAM aliasing.

Using KVMSlot is also wrong.  This is a function that belongs in exec.c.

Regards,

Anthony Liguori

> +    return 0;
> +}
> +
>   static int kvm_set_user_memory_region(KVMState *s, KVMSlot *slot)
>   {
>       struct kvm_userspace_memory_region mem;
> diff --git a/kvm.h b/kvm.h
> index 50b6c01..b2fb3af 100644
> --- a/kvm.h
> +++ b/kvm.h
> @@ -174,6 +174,12 @@ static inline void cpu_synchronize_post_init(CPUState *env)
>       }
>   }
>
> +
> +#if !defined(CONFIG_USER_ONLY)
> +int kvm_physical_memory_addr_from_ram(KVMState *s, ram_addr_t ram_addr,
> +                                      target_phys_addr_t *phys_addr);
> +#endif
> +
>   #endif
>   int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign);
>
>    

  reply	other threads:[~2010-10-20 19:56 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20 17:43 [Qemu-devel] [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 01/10] Set cpuid definition to 0 before initializing it Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 02/10] Add svm cpuid features Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 03/10] signalfd compatibility Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 04/10] iothread: use signalfd Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 05/10] kvm: x86: add mce support Marcelo Tosatti
2010-10-20 19:58   ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 06/10] Export qemu_ram_addr_from_host Marcelo Tosatti
2010-10-20 17:43 ` [Qemu-devel] [PATCH 07/10] Add RAM -> physical addr mapping in MCE simulation Marcelo Tosatti
2010-10-20 19:56   ` Anthony Liguori [this message]
2010-10-20 17:43 ` [Qemu-devel] [PATCH 08/10] MCE: Relay UCR MCE to guest Marcelo Tosatti
2010-10-20 19:51   ` [Qemu-devel] " Anthony Liguori
2010-10-20 20:59     ` Anthony Liguori
2010-10-20 21:33       ` Marcelo Tosatti
2010-10-20 21:28     ` Marcelo Tosatti
2010-10-20 21:56     ` Paolo Bonzini
2010-10-20 22:03       ` Anthony Liguori
2010-10-21  7:41         ` Paolo Bonzini
2010-10-20 17:43 ` [Qemu-devel] [PATCH 09/10] Add savevm/loadvm support for MCE Marcelo Tosatti
2010-10-20 19:54   ` [Qemu-devel] " Anthony Liguori
2010-10-20 17:43 ` [Qemu-devel] [PATCH 10/10] Fix memory leak in register save load due to xsave support Marcelo Tosatti
2010-10-20 19:01 ` [Qemu-devel] Re: [PATCH 00/10] [PULL] qemu-kvm.git uq/master queue Anthony Liguori
2010-10-20 19:05   ` Marcelo Tosatti
2010-10-20 19:15     ` Anthony Liguori
2010-10-20 19:52 ` Anthony Liguori
2010-10-20 21:59 ` Anthony Liguori

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=4CBF4970.5040504@linux.vnet.ibm.com \
    --to=aliguori@linux.vnet.ibm.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ying.huang@intel.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;
as well as URLs for NNTP newsgroup(s).