Message ID | 20200420173838.24672-2-mikelley@microsoft.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Split hyperv-tlfs.h into generic and arch specific files | expand |
On Mon, Apr 20, 2020 at 10:38:35AM -0700, Michael Kelley wrote: > The Hyper-V Reference TSC Page structure is defined twice. struct > ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But > the padding is not needed because the declaration includes a union > with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is > struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. > > Fix the duplication by removing the padding from ms_hyperv_tsc_page. > Fix up the KVM code to use it. Remove the no longer used struct > _HV_REFERENCE_TSC_PAGE. > > There is no functional change. > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > --- > arch/x86/include/asm/hyperv-tlfs.h | 8 -------- > arch/x86/include/asm/kvm_host.h | 2 +- > arch/x86/kvm/hyperv.c | 4 ++-- Paolo, this patch touches KVM code. Let me know how you would like to handle this. Wei.
On 21/04/20 11:29, Wei Liu wrote: > On Mon, Apr 20, 2020 at 10:38:35AM -0700, Michael Kelley wrote: >> The Hyper-V Reference TSC Page structure is defined twice. struct >> ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But >> the padding is not needed because the declaration includes a union >> with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is >> struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. >> >> Fix the duplication by removing the padding from ms_hyperv_tsc_page. >> Fix up the KVM code to use it. Remove the no longer used struct >> _HV_REFERENCE_TSC_PAGE. >> >> There is no functional change. >> >> Signed-off-by: Michael Kelley <mikelley@microsoft.com> >> --- >> arch/x86/include/asm/hyperv-tlfs.h | 8 -------- >> arch/x86/include/asm/kvm_host.h | 2 +- >> arch/x86/kvm/hyperv.c | 4 ++-- > > Paolo, this patch touches KVM code. Let me know how you would like to > handle this. Just include it, I don't expect conflicts. Acked-by: Paolo Bonzini <pbonzini@redhat.com> Paolo
On Tue, Apr 21, 2020 at 01:16:42PM +0200, Paolo Bonzini wrote: > On 21/04/20 11:29, Wei Liu wrote: > > On Mon, Apr 20, 2020 at 10:38:35AM -0700, Michael Kelley wrote: > >> The Hyper-V Reference TSC Page structure is defined twice. struct > >> ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But > >> the padding is not needed because the declaration includes a union > >> with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is > >> struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. > >> > >> Fix the duplication by removing the padding from ms_hyperv_tsc_page. > >> Fix up the KVM code to use it. Remove the no longer used struct > >> _HV_REFERENCE_TSC_PAGE. > >> > >> There is no functional change. > >> > >> Signed-off-by: Michael Kelley <mikelley@microsoft.com> > >> --- > >> arch/x86/include/asm/hyperv-tlfs.h | 8 -------- > >> arch/x86/include/asm/kvm_host.h | 2 +- > >> arch/x86/kvm/hyperv.c | 4 ++-- > > > > Paolo, this patch touches KVM code. Let me know how you would like to > > handle this. > > Just include it, I don't expect conflicts. > > Acked-by: Paolo Bonzini <pbonzini@redhat.com> Ack.
Michael Kelley <mikelley@microsoft.com> writes: > The Hyper-V Reference TSC Page structure is defined twice. struct > ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But > the padding is not needed because the declaration includes a union > with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is > struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. > > Fix the duplication by removing the padding from ms_hyperv_tsc_page. > Fix up the KVM code to use it. Remove the no longer used struct > _HV_REFERENCE_TSC_PAGE. > > There is no functional change. > > Signed-off-by: Michael Kelley <mikelley@microsoft.com> > --- > arch/x86/include/asm/hyperv-tlfs.h | 8 -------- > arch/x86/include/asm/kvm_host.h | 2 +- > arch/x86/kvm/hyperv.c | 4 ++-- > 3 files changed, 3 insertions(+), 11 deletions(-) > > diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h > index 29336574d0bc..0e4d76920957 100644 > --- a/arch/x86/include/asm/hyperv-tlfs.h > +++ b/arch/x86/include/asm/hyperv-tlfs.h > @@ -303,7 +303,6 @@ struct ms_hyperv_tsc_page { > u32 reserved1; > volatile u64 tsc_scale; > volatile s64 tsc_offset; > - u64 reserved2[509]; > } __packed; > > /* > @@ -433,13 +432,6 @@ enum HV_GENERIC_SET_FORMAT { > */ > #define HV_CLOCK_HZ (NSEC_PER_SEC/100) > > -typedef struct _HV_REFERENCE_TSC_PAGE { > - __u32 tsc_sequence; > - __u32 res1; > - __u64 tsc_scale; > - __s64 tsc_offset; > -} __packed HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE; > - > /* Define the number of synthetic interrupt sources. */ > #define HV_SYNIC_SINT_COUNT (16) > /* Define the expected SynIC version. */ > diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h > index 42a2d0d3984a..4698343b9a05 100644 > --- a/arch/x86/include/asm/kvm_host.h > +++ b/arch/x86/include/asm/kvm_host.h > @@ -865,7 +865,7 @@ struct kvm_hv { > u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS]; > u64 hv_crash_ctl; > > - HV_REFERENCE_TSC_PAGE tsc_ref; > + struct ms_hyperv_tsc_page tsc_ref; > > struct idr conn_to_evt; > > diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c > index bcefa9d4e57e..1f3c6fd3cdaa 100644 > --- a/arch/x86/kvm/hyperv.c > +++ b/arch/x86/kvm/hyperv.c > @@ -900,7 +900,7 @@ static int kvm_hv_msr_set_crash_data(struct kvm_vcpu *vcpu, > * These two equivalencies are implemented in this function. > */ > static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info *hv_clock, > - HV_REFERENCE_TSC_PAGE *tsc_ref) > + struct ms_hyperv_tsc_page *tsc_ref) > { > u64 max_mul; > > @@ -941,7 +941,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm, > u64 gfn; > > BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence)); > - BUILD_BUG_ON(offsetof(HV_REFERENCE_TSC_PAGE, tsc_sequence) != 0); > + BUILD_BUG_ON(offsetof(struct ms_hyperv_tsc_page, tsc_sequence) != 0); > > if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE)) > return; Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
diff --git a/arch/x86/include/asm/hyperv-tlfs.h b/arch/x86/include/asm/hyperv-tlfs.h index 29336574d0bc..0e4d76920957 100644 --- a/arch/x86/include/asm/hyperv-tlfs.h +++ b/arch/x86/include/asm/hyperv-tlfs.h @@ -303,7 +303,6 @@ struct ms_hyperv_tsc_page { u32 reserved1; volatile u64 tsc_scale; volatile s64 tsc_offset; - u64 reserved2[509]; } __packed; /* @@ -433,13 +432,6 @@ enum HV_GENERIC_SET_FORMAT { */ #define HV_CLOCK_HZ (NSEC_PER_SEC/100) -typedef struct _HV_REFERENCE_TSC_PAGE { - __u32 tsc_sequence; - __u32 res1; - __u64 tsc_scale; - __s64 tsc_offset; -} __packed HV_REFERENCE_TSC_PAGE, *PHV_REFERENCE_TSC_PAGE; - /* Define the number of synthetic interrupt sources. */ #define HV_SYNIC_SINT_COUNT (16) /* Define the expected SynIC version. */ diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 42a2d0d3984a..4698343b9a05 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -865,7 +865,7 @@ struct kvm_hv { u64 hv_crash_param[HV_X64_MSR_CRASH_PARAMS]; u64 hv_crash_ctl; - HV_REFERENCE_TSC_PAGE tsc_ref; + struct ms_hyperv_tsc_page tsc_ref; struct idr conn_to_evt; diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index bcefa9d4e57e..1f3c6fd3cdaa 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -900,7 +900,7 @@ static int kvm_hv_msr_set_crash_data(struct kvm_vcpu *vcpu, * These two equivalencies are implemented in this function. */ static bool compute_tsc_page_parameters(struct pvclock_vcpu_time_info *hv_clock, - HV_REFERENCE_TSC_PAGE *tsc_ref) + struct ms_hyperv_tsc_page *tsc_ref) { u64 max_mul; @@ -941,7 +941,7 @@ void kvm_hv_setup_tsc_page(struct kvm *kvm, u64 gfn; BUILD_BUG_ON(sizeof(tsc_seq) != sizeof(hv->tsc_ref.tsc_sequence)); - BUILD_BUG_ON(offsetof(HV_REFERENCE_TSC_PAGE, tsc_sequence) != 0); + BUILD_BUG_ON(offsetof(struct ms_hyperv_tsc_page, tsc_sequence) != 0); if (!(hv->hv_tsc_page & HV_X64_MSR_TSC_REFERENCE_ENABLE)) return;
The Hyper-V Reference TSC Page structure is defined twice. struct ms_hyperv_tsc_page has padding out to a full 4 Kbyte page size. But the padding is not needed because the declaration includes a union with HV_HYP_PAGE_SIZE. KVM uses the second definition, which is struct _HV_REFERENCE_TSC_PAGE, because it does not have the padding. Fix the duplication by removing the padding from ms_hyperv_tsc_page. Fix up the KVM code to use it. Remove the no longer used struct _HV_REFERENCE_TSC_PAGE. There is no functional change. Signed-off-by: Michael Kelley <mikelley@microsoft.com> --- arch/x86/include/asm/hyperv-tlfs.h | 8 -------- arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/hyperv.c | 4 ++-- 3 files changed, 3 insertions(+), 11 deletions(-)