[2/2] x86/paravirt: Make the struct paravirt_patch_site packed

Message ID 6dcb20159ded36586c5f7f2ae159e4e030256627.1686301237.git.houwenlong.hwl@antgroup.com
State New
Headers
Series [1/2] x86/paravirt: Use relative reference for original instruction |

Commit Message

Hou Wenlong June 9, 2023, 9:45 a.m. UTC
  Similar to struct alt_instr, make the struct paravirt_patch_site packed
and get rid of all the .align directives. This could save 2 bytes for
one entry on X86_64.

Suggested-by: Nadav Amit <namit@vmware.com>
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
---
 arch/x86/include/asm/paravirt.h       | 2 --
 arch/x86/include/asm/paravirt_types.h | 4 +---
 2 files changed, 1 insertion(+), 5 deletions(-)
  

Comments

Juergen Gross June 9, 2023, 3:11 p.m. UTC | #1
On 09.06.23 11:45, Hou Wenlong wrote:
> Similar to struct alt_instr, make the struct paravirt_patch_site packed
> and get rid of all the .align directives. This could save 2 bytes for
> one entry on X86_64.
> 
> Suggested-by: Nadav Amit <namit@vmware.com>
> Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen
  
Nadav Amit June 9, 2023, 6:25 p.m. UTC | #2
> On Jun 9, 2023, at 2:45 AM, Hou Wenlong <houwenlong.hwl@antgroup.com> wrote:
> 
> Similar to struct alt_instr, make the struct paravirt_patch_site packed
> and get rid of all the .align directives. This could save 2 bytes for
> one entry on X86_64.

Thanks for taking care of it.
  

Patch

diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index 2350ceb43db0..3e5ccacb3893 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -747,11 +747,9 @@  extern void default_banner(void);
 	ops;					\
 772:;						\
 	.pushsection .parainstructions,"a";	\
-	 .align	4;				\
 	 .long 771b-.;				\
 	 .byte ptype;				\
 	 .byte 772b-771b;			\
-	 .align 4;				\
 	.popsection
 
 
diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
index 982a234f5a06..da0547bcd068 100644
--- a/arch/x86/include/asm/paravirt_types.h
+++ b/arch/x86/include/asm/paravirt_types.h
@@ -8,7 +8,7 @@  struct paravirt_patch_site {
 	s32 instr_offset;	/* original instructions */
 	u8 type;		/* type of this instruction */
 	u8 len;			/* length of original instruction */
-};
+} __packed;
 
 /* Lazy mode for batching updates / context switch */
 enum paravirt_lazy_mode {
@@ -270,11 +270,9 @@  extern struct paravirt_patch_template pv_ops;
 #define _paravirt_alt(insn_string, type)		\
 	"771:\n\t" insn_string "\n" "772:\n"		\
 	".pushsection .parainstructions,\"a\"\n"	\
-	"  .align 4\n"					\
 	"  .long 771b-.\n"				\
 	"  .byte " type "\n"				\
 	"  .byte 772b-771b\n"				\
-	"  .align 4\n"					\
 	".popsection\n"
 
 /* Generate patchable code, with the default asm parameters. */