From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Ani Sinha <anisinha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
<qemu-devel@nongnu.org>
Subject: Re: [PATCH] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range
Date: Wed, 11 Oct 2023 17:31:04 +0100 [thread overview]
Message-ID: <20231011173104.000016f5@Huawei.com> (raw)
In-Reply-To: <20231011105335.42296-1-anisinha@redhat.com>
On Wed, 11 Oct 2023 16:23:35 +0530
Ani Sinha <anisinha@redhat.com> wrote:
> pc_get_device_memory_range() finds the device memory size by calculating the
> difference between maxram and ram sizes. This calculation makes sense only when
> maxram is greater than the ram size. Make sure we check for that before calling
> pc_get_device_memory_range().
>
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
Whilst this is similar to other cases, I can't remember or quickly work
out if the 'else' path here is appropriate. Can we add something to the
patch description to talk about that?
For reference it's:
cxl_base = pc_above_4g_end(pcms);
> ---
> hw/i386/pc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f72e2c3b35..948c58171c 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -820,10 +820,12 @@ static void pc_get_device_memory_range(PCMachineState *pcms,
> static uint64_t pc_get_cxl_range_start(PCMachineState *pcms)
> {
> PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> + MachineState *ms = MACHINE(pcms);
> hwaddr cxl_base;
> ram_addr_t size;
>
> - if (pcmc->has_reserved_memory) {
> + if (pcmc->has_reserved_memory &&
> + (ms->ram_size < ms->maxram_size)) {
> pc_get_device_memory_range(pcms, &cxl_base, &size);
> cxl_base += size;
> } else {
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Ani Sinha <anisinha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
<qemu-devel@nongnu.org>
Subject: Re: [PATCH] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range
Date: Wed, 11 Oct 2023 17:31:04 +0100 [thread overview]
Message-ID: <20231011173104.000016f5@Huawei.com> (raw)
Message-ID: <20231011163104.u7laYzyoJzpQ_2Qy9Huvom8MGZQIdPyCmZ15gXfNzXU@z> (raw)
In-Reply-To: <20231011105335.42296-1-anisinha@redhat.com>
On Wed, 11 Oct 2023 16:23:35 +0530
Ani Sinha <anisinha@redhat.com> wrote:
> pc_get_device_memory_range() finds the device memory size by calculating the
> difference between maxram and ram sizes. This calculation makes sense only when
> maxram is greater than the ram size. Make sure we check for that before calling
> pc_get_device_memory_range().
>
> Signed-off-by: Ani Sinha <anisinha@redhat.com>
Whilst this is similar to other cases, I can't remember or quickly work
out if the 'else' path here is appropriate. Can we add something to the
patch description to talk about that?
For reference it's:
cxl_base = pc_above_4g_end(pcms);
> ---
> hw/i386/pc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/hw/i386/pc.c b/hw/i386/pc.c
> index f72e2c3b35..948c58171c 100644
> --- a/hw/i386/pc.c
> +++ b/hw/i386/pc.c
> @@ -820,10 +820,12 @@ static void pc_get_device_memory_range(PCMachineState *pcms,
> static uint64_t pc_get_cxl_range_start(PCMachineState *pcms)
> {
> PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms);
> + MachineState *ms = MACHINE(pcms);
> hwaddr cxl_base;
> ram_addr_t size;
>
> - if (pcmc->has_reserved_memory) {
> + if (pcmc->has_reserved_memory &&
> + (ms->ram_size < ms->maxram_size)) {
> pc_get_device_memory_range(pcms, &cxl_base, &size);
> cxl_base += size;
> } else {
next prev parent reply other threads:[~2023-10-11 16:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-11 10:53 [PATCH] hw/i386/cxl: ensure maxram is greater than ram size for calculating cxl range Ani Sinha
2023-10-11 16:31 ` Jonathan Cameron via [this message]
2023-10-11 16:31 ` Jonathan Cameron
2023-10-12 4:40 ` Ani Sinha
2023-10-12 9:09 ` Jonathan Cameron via
2023-10-12 9:09 ` Jonathan Cameron
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=20231011173104.000016f5@Huawei.com \
--to=qemu-devel@nongnu.org \
--cc=Jonathan.Cameron@Huawei.com \
--cc=anisinha@redhat.com \
--cc=eduardo@habkost.net \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--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 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.