Jan Beulich
2008-Aug-29 12:33 UTC
[Xen-devel] [PATCH] constify microcode hypercall argument
Linux 2.6.27 marks the data pointer in its firmware struct ''const'', and hence, to avoid a compiler warning, Xen''s microcode update interface should be properly properly constified too. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: 2008-08-06/xen/arch/x86/microcode.c ==================================================================--- 2008-08-06.orig/xen/arch/x86/microcode.c 2008-06-12 09:20:38.000000000 +0200 +++ 2008-08-06/xen/arch/x86/microcode.c 2008-08-20 12:33:03.000000000 +0200 @@ -124,7 +124,7 @@ boolean_param("microcode.verbose", verbo /* no concurrent ->write()s are allowed on /dev/cpu/microcode */ static DEFINE_MUTEX(microcode_mutex); -static void __user *user_buffer; /* user area microcode data buffer */ +static const void __user *user_buffer; /* user area microcode data buffer */ static unsigned int user_buffer_size; /* it''s size */ typedef enum mc_error_code { @@ -455,7 +455,7 @@ static int do_microcode_update (void) return error; } -int microcode_update(XEN_GUEST_HANDLE(void) buf, unsigned long len) +int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len) { int ret; Index: 2008-08-06/xen/arch/x86/platform_hypercall.c ==================================================================--- 2008-08-06.orig/xen/arch/x86/platform_hypercall.c 2008-08-01 08:48:42.000000000 +0200 +++ 2008-08-06/xen/arch/x86/platform_hypercall.c 2008-08-20 12:34:23.000000000 +0200 @@ -147,8 +147,7 @@ ret_t do_platform_op(XEN_GUEST_HANDLE(xe case XENPF_microcode_update: { - extern int microcode_update(XEN_GUEST_HANDLE(void), unsigned long len); - XEN_GUEST_HANDLE(void) data; + XEN_GUEST_HANDLE(const_void) data; ret = xsm_microcode(); if ( ret ) Index: 2008-08-06/xen/include/asm-x86/processor.h ==================================================================--- 2008-08-06.orig/xen/include/asm-x86/processor.h 2008-05-07 12:21:37.000000000 +0200 +++ 2008-08-06/xen/include/asm-x86/processor.h 2008-08-20 12:34:43.000000000 +0200 @@ -583,6 +583,8 @@ int rdmsr_hypervisor_regs( int wrmsr_hypervisor_regs( uint32_t idx, uint32_t eax, uint32_t edx); +int microcode_update(XEN_GUEST_HANDLE(const_void), unsigned long len); + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_X86_PROCESSOR_H */ Index: 2008-08-06/xen/include/public/platform.h ==================================================================--- 2008-08-06.orig/xen/include/public/platform.h 2008-05-15 14:51:17.000000000 +0200 +++ 2008-08-06/xen/include/public/platform.h 2008-08-20 12:30:50.000000000 +0200 @@ -97,7 +97,7 @@ DEFINE_XEN_GUEST_HANDLE(xenpf_read_memty #define XENPF_microcode_update 35 struct xenpf_microcode_update { /* IN variables. */ - XEN_GUEST_HANDLE(void) data; /* Pointer to microcode data */ + XEN_GUEST_HANDLE(const_void) data;/* Pointer to microcode data */ uint32_t length; /* Length of microcode data. */ }; typedef struct xenpf_microcode_update xenpf_microcode_update_t; Index: 2008-08-06/xen/include/xen/compat.h ==================================================================--- 2008-08-06.orig/xen/include/xen/compat.h 2008-06-16 10:43:34.000000000 +0200 +++ 2008-08-06/xen/include/xen/compat.h 2008-08-20 13:57:27.000000000 +0200 @@ -19,7 +19,9 @@ type *_[0] __attribute__((__packed__)); \ } __compat_handle_ ## name -#define DEFINE_COMPAT_HANDLE(name) __DEFINE_COMPAT_HANDLE(name, name) +#define DEFINE_COMPAT_HANDLE(name) \ + __DEFINE_COMPAT_HANDLE(name, name); \ + __DEFINE_COMPAT_HANDLE(const_ ## name, const name) #define COMPAT_HANDLE(name) __compat_handle_ ## name /* Is the compat handle a NULL reference? */ _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Christoph Egger
2008-Aug-29 13:55 UTC
Re: [Xen-devel] [PATCH] constify microcode hypercall argument
On Friday 29 August 2008 14:33:08 Jan Beulich wrote:> Linux 2.6.27 marks the data pointer in its firmware struct ''const'', and > hence, to avoid a compiler warning, Xen''s microcode update interface > should be properly properly constified too.What makes you confident, that this reason applies to other operating systems (Solaris, BSD) , too ? Christoph -- AMD Saxony, Dresden, Germany Operating System Research Center Legal Information: AMD Saxony Limited Liability Company & Co. KG Sitz (Geschäftsanschrift): Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland Registergericht Dresden: HRA 4896 vertretungsberechtigter Komplementär: AMD Saxony LLC (Sitz Wilmington, Delaware, USA) Geschäftsführer der AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2008-Aug-29 14:28 UTC
Re: [Xen-devel] [PATCH] constify microcode hypercall argument
>>> Christoph Egger <Christoph.Egger@amd.com> 29.08.08 15:55 >>> >On Friday 29 August 2008 14:33:08 Jan Beulich wrote: >> Linux 2.6.27 marks the data pointer in its firmware struct ''const'', and >> hence, to avoid a compiler warning, Xen''s microcode update interface >> should be properly properly constified too. > >What makes you confident, that this reason applies to other operating systems >(Solaris, BSD) , too ?Adding ''const'' on the consumer side is always safe, as long as the consumer guarantees it won''t violate the promise. The consumer here is Xen, so there are no worries about individual guest OSes. Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel