From: Yang Zhong <yang.zhong@intel.com>
To: "Philippe Mathieu-Daudé" <philmd@redhat.com>
Cc: yang.zhong@intel.com, ehabkost@redhat.com, mst@redhat.com,
richard.henderson@linaro.org, qemu-devel@nongnu.org,
pbonzini@redhat.com
Subject: Re: [PATCH 2/4] hw/i386/sgx: Have sgx_epc_get_section() return a boolean
Date: Sat, 9 Oct 2021 14:14:06 +0800 [thread overview]
Message-ID: <20211009061406.GA14769@yangzhon-Virtual> (raw)
In-Reply-To: <20211007175612.496366-3-philmd@redhat.com>
On Thu, Oct 07, 2021 at 07:56:10PM +0200, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> include/hw/i386/sgx-epc.h | 2 +-
> hw/i386/sgx-stub.c | 2 +-
> hw/i386/sgx.c | 6 +++---
> 3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/i386/sgx-epc.h b/include/hw/i386/sgx-epc.h
> index 65a68ca753a..a6a65be854f 100644
> --- a/include/hw/i386/sgx-epc.h
> +++ b/include/hw/i386/sgx-epc.h
> @@ -55,7 +55,7 @@ typedef struct SGXEPCState {
> int nr_sections;
> } SGXEPCState;
>
> -int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size);
> +bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size);
>
> static inline uint64_t sgx_epc_above_4g_end(SGXEPCState *sgx_epc)
> {
> diff --git a/hw/i386/sgx-stub.c b/hw/i386/sgx-stub.c
> index 3be9f5ca32c..45c473119ef 100644
> --- a/hw/i386/sgx-stub.c
> +++ b/hw/i386/sgx-stub.c
> @@ -20,7 +20,7 @@ void pc_machine_init_sgx_epc(PCMachineState *pcms)
> memset(&pcms->sgx_epc, 0, sizeof(SGXEPCState));
> }
>
> -int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
> +bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
> {
> g_assert_not_reached();
> }
> diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c
> index e481e9358f1..29724ff8f08 100644
> --- a/hw/i386/sgx.c
> +++ b/hw/i386/sgx.c
> @@ -115,13 +115,13 @@ SGXInfo *sgx_get_info(Error **errp)
> return info;
> }
>
> -int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
> +bool sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
> {
> PCMachineState *pcms = PC_MACHINE(qdev_get_machine());
> SGXEPCDevice *epc;
>
> if (pcms->sgx_epc.size == 0 || pcms->sgx_epc.nr_sections <= section_nr) {
> - return 1;
> + return true;
If return boolean, here should be return false, Sean wrote this(return 0 or 1) like Linux kernel did.
> }
>
> epc = pcms->sgx_epc.sections[section_nr];
> @@ -129,7 +129,7 @@ int sgx_epc_get_section(int section_nr, uint64_t *addr, uint64_t *size)
> *addr = epc->addr;
> *size = memory_device_get_region_size(MEMORY_DEVICE(epc), &error_fatal);
>
> - return 0;
> + return false;
Here should be return true.
Then in the ./target/i386/cpu.c file,
if (sgx_epc_get_section(count - 2, &epc_addr, &epc_size))
should be
if (!sgx_epc_get_section(count - 2, &epc_addr, &epc_size))
Yang
> }
>
> void pc_machine_init_sgx_epc(PCMachineState *pcms)
> --
> 2.31.1
next prev parent reply other threads:[~2021-10-09 6:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 17:56 [PATCH 0/4] hw/i386/sgx: Housekeeping around SGX Philippe Mathieu-Daudé
2021-10-07 17:56 ` [PATCH 1/4] MAINTAINERS: Cover SGX documentation file with X86/KVM section Philippe Mathieu-Daudé
2021-10-07 17:56 ` [PATCH 2/4] hw/i386/sgx: Have sgx_epc_get_section() return a boolean Philippe Mathieu-Daudé
2021-10-09 6:14 ` Yang Zhong [this message]
2021-10-07 17:56 ` [PATCH 3/4] hw/i386/sgx: Move qmp_query_sgx_capabilities() to hw/i386/sgx.c Philippe Mathieu-Daudé
2021-10-07 17:56 ` [PATCH 4/4] hw/i386/sgx: Move qmp_query_sgx() and hmp_info_sgx() " Philippe Mathieu-Daudé
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=20211009061406.GA14769@yangzhon-Virtual \
--to=yang.zhong@intel.com \
--cc=ehabkost@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--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.