Message ID | 1347006389-543-3-git-send-email-liusheng@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
On 2012-09-07 10:26, Liu Sheng wrote: > updated the head file from kernel for readonly memory > feature. > > Signed-off-by: Liu Sheng <liusheng@linux.vnet.ibm.com> > --- > linux-headers/asm-x86/kvm.h | 1 + > linux-headers/linux/kvm.h | 16 +++++++++++++--- > 2 files changed, 14 insertions(+), 3 deletions(-) > > diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h > index 246617e..521bf25 100644 > --- a/linux-headers/asm-x86/kvm.h > +++ b/linux-headers/asm-x86/kvm.h > @@ -25,6 +25,7 @@ > #define __KVM_HAVE_DEBUGREGS > #define __KVM_HAVE_XSAVE > #define __KVM_HAVE_XCRS > +#define __KVM_HAVE_READONLY_MEM > > /* Architectural interrupt line count. */ > #define KVM_NR_INTERRUPTS 256 > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h > index 4b9e575..02fae9e 100644 > --- a/linux-headers/linux/kvm.h > +++ b/linux-headers/linux/kvm.h > @@ -101,9 +101,13 @@ struct kvm_userspace_memory_region { > __u64 userspace_addr; /* start of the userspace allocated memory */ > }; > > -/* for kvm_memory_region::flags */ > -#define KVM_MEM_LOG_DIRTY_PAGES 1UL > -#define KVM_MEMSLOT_INVALID (1UL << 1) > +/* > + * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, > + * other bits are reserved for kvm internal use which are defined in > + * include/linux/kvm_host.h. > + */ > +#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) > +#define KVM_MEM_READONLY (1UL << 1) > > /* for KVM_IRQ_LINE */ > struct kvm_irq_level { > @@ -222,6 +226,9 @@ struct kvm_run { > __u8 data[8]; > __u32 len; > __u8 is_write; > +#ifdef __KVM_HAVE_READONLY_MEM > + __u8 write_readonly_mem; > +#endif > } mmio; > /* KVM_EXIT_HYPERCALL */ > struct { > @@ -618,6 +625,9 @@ struct kvm_ppc_smmu_info { > #define KVM_CAP_PPC_GET_SMMU_INFO 78 > #define KVM_CAP_S390_COW 79 > #define KVM_CAP_PPC_ALLOC_HTAB 80 > +#ifdef __KVM_HAVE_READONLY_MEM > +#define KVM_CAP_READONLY_MEM 81 > +#endif Sorry for commenting on the wrong patch, this must be fixed in the kernel: no more conditional CAPs, please. Usually, they only require #ifdef messes in QEMU (see patch 3). Jan
Hi Jan, Thanks for your review. On 09/07/2012 04:49 PM, Jan Kiszka wrote: >> +#ifdef __KVM_HAVE_READONLY_MEM >> + __u8 write_readonly_mem; >> +#endif >> } mmio; >> /* KVM_EXIT_HYPERCALL */ >> struct { >> @@ -618,6 +625,9 @@ struct kvm_ppc_smmu_info { >> #define KVM_CAP_PPC_GET_SMMU_INFO 78 >> #define KVM_CAP_S390_COW 79 >> #define KVM_CAP_PPC_ALLOC_HTAB 80 >> +#ifdef __KVM_HAVE_READONLY_MEM >> +#define KVM_CAP_READONLY_MEM 81 >> +#endif > > Sorry for commenting on the wrong patch, this must be fixed in the > kernel: no more conditional CAPs, please. There are some common code depend on KVM_CAP_READONLY_MEM, such as, check_memory_region_flags() and write_readonly_mem field in mmio-exit-info. Yes, we can use #ifdef CONFIG_X86 to enable it only on x86, but it is hard to expand this feather to other arches in the further. So, i used __KVM_HAVE_READONLY_MEM and only defined it on x86. :)
On 2012-09-07 11:39, Xiao Guangrong wrote: > Hi Jan, > > Thanks for your review. > > On 09/07/2012 04:49 PM, Jan Kiszka wrote: > >>> +#ifdef __KVM_HAVE_READONLY_MEM >>> + __u8 write_readonly_mem; >>> +#endif >>> } mmio; >>> /* KVM_EXIT_HYPERCALL */ >>> struct { >>> @@ -618,6 +625,9 @@ struct kvm_ppc_smmu_info { >>> #define KVM_CAP_PPC_GET_SMMU_INFO 78 >>> #define KVM_CAP_S390_COW 79 >>> #define KVM_CAP_PPC_ALLOC_HTAB 80 >>> +#ifdef __KVM_HAVE_READONLY_MEM >>> +#define KVM_CAP_READONLY_MEM 81 >>> +#endif >> >> Sorry for commenting on the wrong patch, this must be fixed in the >> kernel: no more conditional CAPs, please. > > There are some common code depend on KVM_CAP_READONLY_MEM, such as, Let is depend on KVM_HAVE or some CONFIG_xxx, not on something that is going to be exported as userspace API. Jan > check_memory_region_flags() and write_readonly_mem field in mmio-exit-info. > > Yes, we can use #ifdef CONFIG_X86 to enable it only on x86, but it > is hard to expand this feather to other arches in the further. > > So, i used __KVM_HAVE_READONLY_MEM and only defined it on x86. :) >
diff --git a/linux-headers/asm-x86/kvm.h b/linux-headers/asm-x86/kvm.h index 246617e..521bf25 100644 --- a/linux-headers/asm-x86/kvm.h +++ b/linux-headers/asm-x86/kvm.h @@ -25,6 +25,7 @@ #define __KVM_HAVE_DEBUGREGS #define __KVM_HAVE_XSAVE #define __KVM_HAVE_XCRS +#define __KVM_HAVE_READONLY_MEM /* Architectural interrupt line count. */ #define KVM_NR_INTERRUPTS 256 diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 4b9e575..02fae9e 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -101,9 +101,13 @@ struct kvm_userspace_memory_region { __u64 userspace_addr; /* start of the userspace allocated memory */ }; -/* for kvm_memory_region::flags */ -#define KVM_MEM_LOG_DIRTY_PAGES 1UL -#define KVM_MEMSLOT_INVALID (1UL << 1) +/* + * The bit 0 ~ bit 15 of kvm_memory_region::flags are visible for userspace, + * other bits are reserved for kvm internal use which are defined in + * include/linux/kvm_host.h. + */ +#define KVM_MEM_LOG_DIRTY_PAGES (1UL << 0) +#define KVM_MEM_READONLY (1UL << 1) /* for KVM_IRQ_LINE */ struct kvm_irq_level { @@ -222,6 +226,9 @@ struct kvm_run { __u8 data[8]; __u32 len; __u8 is_write; +#ifdef __KVM_HAVE_READONLY_MEM + __u8 write_readonly_mem; +#endif } mmio; /* KVM_EXIT_HYPERCALL */ struct { @@ -618,6 +625,9 @@ struct kvm_ppc_smmu_info { #define KVM_CAP_PPC_GET_SMMU_INFO 78 #define KVM_CAP_S390_COW 79 #define KVM_CAP_PPC_ALLOC_HTAB 80 +#ifdef __KVM_HAVE_READONLY_MEM +#define KVM_CAP_READONLY_MEM 81 +#endif #ifdef KVM_CAP_IRQ_ROUTING
updated the head file from kernel for readonly memory feature. Signed-off-by: Liu Sheng <liusheng@linux.vnet.ibm.com> --- linux-headers/asm-x86/kvm.h | 1 + linux-headers/linux/kvm.h | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-)