Message ID | 20211002125317.3418648-16-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | target/i386/sev: Housekeeping SEV + measured Linux SEV guest | expand |
On 02/10/21 14:53, Philippe Mathieu-Daudé wrote: > Move qmp_sev_inject_launch_secret() from monitor.c to sev.c > and make sev_inject_launch_secret() static. We don't need the > stub anymore, remove it. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > target/i386/monitor.c | 31 ------------------------------- > target/i386/sev-sysemu-stub.c | 6 +++--- > target/i386/sev.c | 31 +++++++++++++++++++++++++++++++ > 3 files changed, 34 insertions(+), 34 deletions(-) > > diff --git a/target/i386/monitor.c b/target/i386/monitor.c > index c05d70252a2..188203da6f2 100644 > --- a/target/i386/monitor.c > +++ b/target/i386/monitor.c > @@ -733,37 +733,6 @@ SevCapability *qmp_query_sev_capabilities(Error **errp) > return sev_get_capabilities(errp); > } > > -#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" > -struct sev_secret_area { > - uint32_t base; > - uint32_t size; > -}; > - > -void qmp_sev_inject_launch_secret(const char *packet_hdr, > - const char *secret, > - bool has_gpa, uint64_t gpa, > - Error **errp) > -{ > - if (!sev_enabled()) { > - error_setg(errp, QERR_UNSUPPORTED); > - return; > - } > - if (!has_gpa) { > - uint8_t *data; > - struct sev_secret_area *area; > - > - if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { > - error_setg(errp, "SEV: no secret area found in OVMF," > - " gpa must be specified."); > - return; > - } > - area = (struct sev_secret_area *)data; > - gpa = area->base; > - } > - > - sev_inject_launch_secret(packet_hdr, secret, gpa, errp); > -} > - > SGXInfo *qmp_query_sgx(Error **errp) > { > return sgx_get_info(errp); > diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c > index 813b9a6a03b..66b69540aa5 100644 > --- a/target/i386/sev-sysemu-stub.c > +++ b/target/i386/sev-sysemu-stub.c > @@ -33,10 +33,10 @@ SevCapability *sev_get_capabilities(Error **errp) > return NULL; > } > > -int sev_inject_launch_secret(const char *hdr, const char *secret, > - uint64_t gpa, Error **errp) > +void qmp_sev_inject_launch_secret(const char *packet_header, const char *secret, > + bool has_gpa, uint64_t gpa, Error **errp) > { > - return 1; > + error_setg(errp, QERR_UNSUPPORTED); > } > > int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) > diff --git a/target/i386/sev.c b/target/i386/sev.c > index 91a217bbb85..2198d550be2 100644 > --- a/target/i386/sev.c > +++ b/target/i386/sev.c > @@ -949,6 +949,37 @@ int sev_inject_launch_secret(const char *packet_hdr, const char *secret, > return 0; > } > > +#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" > +struct sev_secret_area { > + uint32_t base; > + uint32_t size; > +}; > + > +void qmp_sev_inject_launch_secret(const char *packet_hdr, > + const char *secret, > + bool has_gpa, uint64_t gpa, > + Error **errp) > +{ > + if (!sev_enabled()) { > + error_setg(errp, QERR_UNSUPPORTED); > + return; > + } > + if (!has_gpa) { > + uint8_t *data; > + struct sev_secret_area *area; > + > + if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { > + error_setg(errp, "SEV: no secret area found in OVMF," > + " gpa must be specified."); > + return; > + } > + area = (struct sev_secret_area *)data; > + gpa = area->base; > + } > + > + sev_inject_launch_secret(packet_hdr, secret, gpa, errp); > +} > + > static int > sev_es_parse_reset_block(SevInfoBlock *info, uint32_t *addr) > { > Ok, this indirectly addresses my comment on patch 5. Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/target/i386/monitor.c b/target/i386/monitor.c index c05d70252a2..188203da6f2 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -733,37 +733,6 @@ SevCapability *qmp_query_sev_capabilities(Error **errp) return sev_get_capabilities(errp); } -#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" -struct sev_secret_area { - uint32_t base; - uint32_t size; -}; - -void qmp_sev_inject_launch_secret(const char *packet_hdr, - const char *secret, - bool has_gpa, uint64_t gpa, - Error **errp) -{ - if (!sev_enabled()) { - error_setg(errp, QERR_UNSUPPORTED); - return; - } - if (!has_gpa) { - uint8_t *data; - struct sev_secret_area *area; - - if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { - error_setg(errp, "SEV: no secret area found in OVMF," - " gpa must be specified."); - return; - } - area = (struct sev_secret_area *)data; - gpa = area->base; - } - - sev_inject_launch_secret(packet_hdr, secret, gpa, errp); -} - SGXInfo *qmp_query_sgx(Error **errp) { return sgx_get_info(errp); diff --git a/target/i386/sev-sysemu-stub.c b/target/i386/sev-sysemu-stub.c index 813b9a6a03b..66b69540aa5 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -33,10 +33,10 @@ SevCapability *sev_get_capabilities(Error **errp) return NULL; } -int sev_inject_launch_secret(const char *hdr, const char *secret, - uint64_t gpa, Error **errp) +void qmp_sev_inject_launch_secret(const char *packet_header, const char *secret, + bool has_gpa, uint64_t gpa, Error **errp) { - return 1; + error_setg(errp, QERR_UNSUPPORTED); } int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp) diff --git a/target/i386/sev.c b/target/i386/sev.c index 91a217bbb85..2198d550be2 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -949,6 +949,37 @@ int sev_inject_launch_secret(const char *packet_hdr, const char *secret, return 0; } +#define SEV_SECRET_GUID "4c2eb361-7d9b-4cc3-8081-127c90d3d294" +struct sev_secret_area { + uint32_t base; + uint32_t size; +}; + +void qmp_sev_inject_launch_secret(const char *packet_hdr, + const char *secret, + bool has_gpa, uint64_t gpa, + Error **errp) +{ + if (!sev_enabled()) { + error_setg(errp, QERR_UNSUPPORTED); + return; + } + if (!has_gpa) { + uint8_t *data; + struct sev_secret_area *area; + + if (!pc_system_ovmf_table_find(SEV_SECRET_GUID, &data, NULL)) { + error_setg(errp, "SEV: no secret area found in OVMF," + " gpa must be specified."); + return; + } + area = (struct sev_secret_area *)data; + gpa = area->base; + } + + sev_inject_launch_secret(packet_hdr, secret, gpa, errp); +} + static int sev_es_parse_reset_block(SevInfoBlock *info, uint32_t *addr) {
Move qmp_sev_inject_launch_secret() from monitor.c to sev.c and make sev_inject_launch_secret() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- target/i386/monitor.c | 31 ------------------------------- target/i386/sev-sysemu-stub.c | 6 +++--- target/i386/sev.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 34 deletions(-)