Message ID | 20211002125317.3418648-18-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_query_sev_launch_measure() from monitor.c to sev.c > and make sev_get_launch_measurement() static. We don't need the > stub anymore, remove it. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > target/i386/sev_i386.h | 1 - > target/i386/monitor.c | 17 ----------------- > target/i386/sev-sysemu-stub.c | 3 ++- > target/i386/sev.c | 20 ++++++++++++++++++-- > 4 files changed, 20 insertions(+), 21 deletions(-) > > diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h > index 8d9388d8c5c..1699376ad87 100644 > --- a/target/i386/sev_i386.h > +++ b/target/i386/sev_i386.h > @@ -25,7 +25,6 @@ > #define SEV_POLICY_SEV 0x20 > > extern SevInfo *sev_get_info(void); > -extern char *sev_get_launch_measurement(void); > > int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); > int sev_inject_launch_secret(const char *hdr, const char *secret, > diff --git a/target/i386/monitor.c b/target/i386/monitor.c > index da36522fa15..0b38e970c73 100644 > --- a/target/i386/monitor.c > +++ b/target/i386/monitor.c > @@ -711,23 +711,6 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict) > qapi_free_SevInfo(info); > } > > -SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) > -{ > - char *data; > - SevLaunchMeasureInfo *info; > - > - data = sev_get_launch_measurement(); > - if (!data) { > - error_setg(errp, "Measurement is not available"); > - return NULL; > - } > - > - info = g_malloc0(sizeof(*info)); > - info->data = data; > - > - return info; > -} > - > 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 cc486a1afbe..355391c16c4 100644 > --- a/target/i386/sev-sysemu-stub.c > +++ b/target/i386/sev-sysemu-stub.c > @@ -22,8 +22,9 @@ SevInfo *sev_get_info(void) > return NULL; > } > > -char *sev_get_launch_measurement(void) > +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) > { > + error_setg(errp, QERR_UNSUPPORTED); > return NULL; > } > > diff --git a/target/i386/sev.c b/target/i386/sev.c > index fce007d6749..8e9cce62196 100644 > --- a/target/i386/sev.c > +++ b/target/i386/sev.c > @@ -718,8 +718,7 @@ free_measurement: > g_free(measurement); > } > > -char * > -sev_get_launch_measurement(void) > +static char *sev_get_launch_measurement(void) > { > if (sev_guest && > sev_guest->state >= SEV_STATE_LAUNCH_SECRET) { > @@ -729,6 +728,23 @@ sev_get_launch_measurement(void) > return NULL; > } > > +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) > +{ > + char *data; > + SevLaunchMeasureInfo *info; > + > + data = sev_get_launch_measurement(); > + if (!data) { > + error_setg(errp, "Measurement is not available"); > + return NULL; > + } > + > + info = g_malloc0(sizeof(*info)); > + info->data = data; > + > + return info; > +} > + > static Notifier sev_machine_done_notify = { > .notify = sev_launch_get_measure, > }; > Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/target/i386/sev_i386.h b/target/i386/sev_i386.h index 8d9388d8c5c..1699376ad87 100644 --- a/target/i386/sev_i386.h +++ b/target/i386/sev_i386.h @@ -25,7 +25,6 @@ #define SEV_POLICY_SEV 0x20 extern SevInfo *sev_get_info(void); -extern char *sev_get_launch_measurement(void); int sev_encrypt_flash(uint8_t *ptr, uint64_t len, Error **errp); int sev_inject_launch_secret(const char *hdr, const char *secret, diff --git a/target/i386/monitor.c b/target/i386/monitor.c index da36522fa15..0b38e970c73 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -711,23 +711,6 @@ void hmp_info_sev(Monitor *mon, const QDict *qdict) qapi_free_SevInfo(info); } -SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) -{ - char *data; - SevLaunchMeasureInfo *info; - - data = sev_get_launch_measurement(); - if (!data) { - error_setg(errp, "Measurement is not available"); - return NULL; - } - - info = g_malloc0(sizeof(*info)); - info->data = data; - - return info; -} - 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 cc486a1afbe..355391c16c4 100644 --- a/target/i386/sev-sysemu-stub.c +++ b/target/i386/sev-sysemu-stub.c @@ -22,8 +22,9 @@ SevInfo *sev_get_info(void) return NULL; } -char *sev_get_launch_measurement(void) +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) { + error_setg(errp, QERR_UNSUPPORTED); return NULL; } diff --git a/target/i386/sev.c b/target/i386/sev.c index fce007d6749..8e9cce62196 100644 --- a/target/i386/sev.c +++ b/target/i386/sev.c @@ -718,8 +718,7 @@ free_measurement: g_free(measurement); } -char * -sev_get_launch_measurement(void) +static char *sev_get_launch_measurement(void) { if (sev_guest && sev_guest->state >= SEV_STATE_LAUNCH_SECRET) { @@ -729,6 +728,23 @@ sev_get_launch_measurement(void) return NULL; } +SevLaunchMeasureInfo *qmp_query_sev_launch_measure(Error **errp) +{ + char *data; + SevLaunchMeasureInfo *info; + + data = sev_get_launch_measurement(); + if (!data) { + error_setg(errp, "Measurement is not available"); + return NULL; + } + + info = g_malloc0(sizeof(*info)); + info->data = data; + + return info; +} + static Notifier sev_machine_done_notify = { .notify = sev_launch_get_measure, };
Move qmp_query_sev_launch_measure() from monitor.c to sev.c and make sev_get_launch_measurement() static. We don't need the stub anymore, remove it. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- target/i386/sev_i386.h | 1 - target/i386/monitor.c | 17 ----------------- target/i386/sev-sysemu-stub.c | 3 ++- target/i386/sev.c | 20 ++++++++++++++++++-- 4 files changed, 20 insertions(+), 21 deletions(-)