Re: [PATCH v2 12/12] x86/paravirt: have only one paravirt patch function

2020-11-20 Thread kernel test robot
Hi Juergen,

I love your patch! Perhaps something to improve:

[auto build test WARNING on v5.10-rc4]
[also build test WARNING on next-20201120]
[cannot apply to tip/x86/core xen-tip/linux-next tip/x86/asm]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:
https://github.com/0day-ci/linux/commits/Juergen-Gross/x86-major-paravirt-cleanup/20201120-194934
base:09162bc32c880a791c6c0668ce0745cf7958f576
config: x86_64-randconfig-r014-20201120 (attached as .config)
compiler: clang version 12.0.0 (https://github.com/llvm/llvm-project 
3ded927cf80ac519f9f9c4664fef08787f7c537d)
reproduce (this is a W=1 build):
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# install x86_64 cross compiling tool for clang build
# apt-get install binutils-x86-64-linux-gnu
# 
https://github.com/0day-ci/linux/commit/340df5e02c66ec37486a1f31e6497a22dab65059
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review 
Juergen-Gross/x86-major-paravirt-cleanup/20201120-194934
git checkout 340df5e02c66ec37486a1f31e6497a22dab65059
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot 

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/paravirt.c:124:10: warning: no previous prototype for 
>> function 'paravirt_patch_insns' [-Wmissing-prototypes]
   unsigned paravirt_patch_insns(void *insn_buff, unsigned len,
^
   arch/x86/kernel/paravirt.c:124:1: note: declare 'static' if the function is 
not intended to be used outside of this translation unit
   unsigned paravirt_patch_insns(void *insn_buff, unsigned len,
   ^
   static 
   1 warning generated.

vim +/paravirt_patch_insns +124 arch/x86/kernel/paravirt.c

63f70270ccd981c arch/i386/kernel/paravirt.c Jeremy Fitzhardinge 2007-05-02  123 
 
1fc654cf6e04b40 arch/x86/kernel/paravirt.c  Ingo Molnar 2019-04-25 @124 
 unsigned paravirt_patch_insns(void *insn_buff, unsigned len,
63f70270ccd981c arch/i386/kernel/paravirt.c Jeremy Fitzhardinge 2007-05-02  125 
  const char *start, const char *end)
63f70270ccd981c arch/i386/kernel/paravirt.c Jeremy Fitzhardinge 2007-05-02  126 
 {
63f70270ccd981c arch/i386/kernel/paravirt.c Jeremy Fitzhardinge 2007-05-02  127 
unsigned insn_len = end - start;
63f70270ccd981c arch/i386/kernel/paravirt.c Jeremy Fitzhardinge 2007-05-02  128 
 
2777cae2b19d4a0 arch/x86/kernel/paravirt.c  Ingo Molnar 2019-04-25  129 
/* Alternative instruction is too large for the patch site and we 
cannot continue: */
2777cae2b19d4a0 arch/x86/kernel/paravirt.c  Ingo Molnar 2019-04-25  130 
BUG_ON(insn_len > len || start == NULL);
2777cae2b19d4a0 arch/x86/kernel/paravirt.c  Ingo Molnar 2019-04-25  131 
 
1fc654cf6e04b40 arch/x86/kernel/paravirt.c  Ingo Molnar 2019-04-25  132 
memcpy(insn_buff, start, insn_len);
139ec7c416248b9 arch/i386/kernel/paravirt.c Rusty Russell   2006-12-07  133 
 
139ec7c416248b9 arch/i386/kernel/paravirt.c Rusty Russell   2006-12-07  134 
return insn_len;
139ec7c416248b9 arch/i386/kernel/paravirt.c Rusty Russell   2006-12-07  135 
 }
139ec7c416248b9 arch/i386/kernel/paravirt.c Rusty Russell   2006-12-07  136 
 

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

[PATCH v2 12/12] x86/paravirt: have only one paravirt patch function

2020-11-20 Thread Juergen Gross via Virtualization
There is no need any longer to have different paravirt patch functions
for native and Xen. Eliminate native_patch() and rename
paravirt_patch_default() to paravirt_patch().

Signed-off-by: Juergen Gross 
---
 arch/x86/include/asm/paravirt_types.h | 19 +--
 arch/x86/kernel/Makefile  |  3 +--
 arch/x86/kernel/alternative.c |  2 +-
 arch/x86/kernel/paravirt.c|  7 ++-
 arch/x86/kernel/paravirt_patch.c  | 11 ---
 arch/x86/xen/enlighten_pv.c   |  1 -
 6 files changed, 5 insertions(+), 38 deletions(-)
 delete mode 100644 arch/x86/kernel/paravirt_patch.c

diff --git a/arch/x86/include/asm/paravirt_types.h 
b/arch/x86/include/asm/paravirt_types.h
index 481d3b667005..bb79e21e1ead 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -74,19 +74,6 @@ struct pv_info {
const char *name;
 };
 
-struct pv_init_ops {
-   /*
-* Patch may replace one of the defined code sequences with
-* arbitrary code, subject to the same register constraints.
-* This generally means the code is not free to clobber any
-* registers other than EAX.  The patch function should return
-* the number of bytes of code generated, as we nop pad the
-* rest in generic code.
-*/
-   unsigned (*patch)(u8 type, void *insn_buff,
- unsigned long addr, unsigned len);
-} __no_randomize_layout;
-
 #ifdef CONFIG_PARAVIRT_XXL
 struct pv_lazy_ops {
/* Set deferred update mode, used for batching operations. */
@@ -282,7 +269,6 @@ struct pv_lock_ops {
  * number for each function using the offset which we use to indicate
  * what to patch. */
 struct paravirt_patch_template {
-   struct pv_init_ops  init;
struct pv_cpu_ops   cpu;
struct pv_irq_ops   irq;
struct pv_mmu_ops   mmu;
@@ -323,10 +309,7 @@ extern void (*paravirt_iret)(void);
 /* Simple instruction patching code. */
 #define NATIVE_LABEL(a,x,b) "\n\t.globl " a #x "_" #b "\n" a #x "_" #b ":\n\t"
 
-unsigned paravirt_patch_default(u8 type, void *insn_buff, unsigned long addr, 
unsigned len);
-unsigned paravirt_patch_insns(void *insn_buff, unsigned len, const char 
*start, const char *end);
-
-unsigned native_patch(u8 type, void *insn_buff, unsigned long addr, unsigned 
len);
+unsigned paravirt_patch(u8 type, void *insn_buff, unsigned long addr, unsigned 
len);
 
 int paravirt_disable_iospace(void);
 
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index 68608bd892c0..61f52f95670b 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -35,7 +35,6 @@ KASAN_SANITIZE_sev-es.o   
:= n
 KCSAN_SANITIZE := n
 
 OBJECT_FILES_NON_STANDARD_test_nx.o:= y
-OBJECT_FILES_NON_STANDARD_paravirt_patch.o := y
 
 ifdef CONFIG_FRAME_POINTER
 OBJECT_FILES_NON_STANDARD_ftrace_$(BITS).o := y
@@ -122,7 +121,7 @@ obj-$(CONFIG_AMD_NB)+= amd_nb.o
 obj-$(CONFIG_DEBUG_NMI_SELFTEST) += nmi_selftest.o
 
 obj-$(CONFIG_KVM_GUEST)+= kvm.o kvmclock.o
-obj-$(CONFIG_PARAVIRT) += paravirt.o paravirt_patch.o
+obj-$(CONFIG_PARAVIRT) += paravirt.o
 obj-$(CONFIG_PARAVIRT_SPINLOCKS)+= paravirt-spinlocks.o
 obj-$(CONFIG_PARAVIRT_CLOCK)   += pvclock.o
 obj-$(CONFIG_X86_PMEM_LEGACY_DEVICE) += pmem.o
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index f8f9700719cf..7ed2c3992eb3 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -617,7 +617,7 @@ void __init_or_module apply_paravirt(struct 
paravirt_patch_site *start,
BUG_ON(p->len > MAX_PATCH_LEN);
/* prep the buffer with the original instructions */
memcpy(insn_buff, p->instr, p->len);
-   used = pv_ops.init.patch(p->type, insn_buff, (unsigned 
long)p->instr, p->len);
+   used = paravirt_patch(p->type, insn_buff, (unsigned 
long)p->instr, p->len);
 
BUG_ON(used > p->len);
 
diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
index db6ae7f7c14e..f05404844245 100644
--- a/arch/x86/kernel/paravirt.c
+++ b/arch/x86/kernel/paravirt.c
@@ -99,8 +99,8 @@ void __init native_pv_lock_init(void)
static_branch_disable(_spin_lock_key);
 }
 
-unsigned paravirt_patch_default(u8 type, void *insn_buff,
-   unsigned long addr, unsigned len)
+unsigned paravirt_patch(u8 type, void *insn_buff, unsigned long addr,
+   unsigned len)
 {
/*
 * Neat trick to map patch type back to the call within the
@@ -255,9 +255,6 @@ struct pv_info pv_info = {
 #define PTE_IDENT  __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
 
 struct paravirt_patch_template pv_ops = {
-   /* Init ops. */
-   .init.patch = native_patch,
-
/* Cpu ops. */
.cpu.io_delay