All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	Juergen Gross <jgross@suse.com>,
	Andy Lutomirski <luto@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Sasha Levin <alexander.levin@verizon.com>,
	live-patching@vger.kernel.org, Jiri Slaby <jslaby@suse.cz>,
	Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Mike Galbraith <efault@gmx.de>,
	Chris Wright <chrisw@sous-sol.org>,
	Alok Kataria <akataria@vmware.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	virtualization@lists.linux-foundation.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	xen-devel@lists.xenproject.org,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH 08/13] x86/paravirt: Clean up paravirt_types.h
Date: Wed, 22 Nov 2017 21:46:10 +0100	[thread overview]
Message-ID: <20171122204610.mtpjea2wbeuey5mp@pd.tnic> (raw)
In-Reply-To: <38b16ecbfa88b41239e8a87ce1d8330fea7a2b3a.1507128293.git.jpoimboe@redhat.com>

On Wed, Oct 04, 2017 at 10:58:29AM -0500, Josh Poimboeuf wrote:
> Make paravirt_types.h more understandable:
> 
> - Use more consistent and logical naming
> - Simplify interfaces
> - Put related macros together
> - Improve whitespace
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  arch/x86/include/asm/paravirt_types.h | 104 ++++++++++++++++++----------------
>  1 file changed, 54 insertions(+), 50 deletions(-)
> 
> diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
> index 01f9e10983c1..5656aea79412 100644
> --- a/arch/x86/include/asm/paravirt_types.h
> +++ b/arch/x86/include/asm/paravirt_types.h

...

> @@ -388,13 +361,46 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf,
>  
>  int paravirt_disable_iospace(void);
>  
> +
>  /*
> - * This generates an indirect call based on the operation type number.
> - * The type number, computed in PARAVIRT_PATCH, is derived from the
> - * offset into the paravirt_patch_template structure, and can therefore be
> - * freely converted back into a structure offset.
> + * Generate some code, and mark it as patchable by apply_paravirt().
>   */
> -#define PARAVIRT_CALL	"call *%c[paravirt_opptr];"
> +#define _PV_SITE(insn_string, type, clobber)				\
> +	"771:\n\t" insn_string "\n" "772:\n"				\

You can merge the last two strings into one.

Also, s/insn_string/insns/ so that it is the same as in paravirt-asm.h
PV_SITE definition. Ditto for s/clobber/clobbers/ I.e., in general,
have the same parameter names in the respective macros so that they can
be parsed visually quickly and reader can say, aha, I see, that's that
param from the asm version of the macro.

> +	".pushsection .parainstructions,\"a\"\n"			\
> +	_ASM_ALIGN "\n"							\
> +	_ASM_PTR " 771b\n"						\
> +	"  .byte " type "\n"						\
> +	"  .byte 772b-771b\n"						\
> +	"  .short " clobber "\n"					\
> +	".popsection\n"
> +
> +#define PARAVIRT_PATCH(x)						\

Btw, that macro's name doesn't tell me anything: it should be
PV_INSN_TYPE or so.

> +	(offsetof(struct paravirt_patch_template, x) / sizeof(void *))
> +
> +#define PV_STRINGIFY(constraint)	"%c[" __stringify(constraint) "]"
> +
> +#define PV_CALL_CONSTRAINT		pv_op_ptr
> +#define PV_TYPE_CONSTRAINT		pv_typenum
> +#define PV_CLBR_CONSTRAINT		pv_clobber
> +
> +#define PV_CALL_CONSTRAINT_STR		PV_STRINGIFY(PV_CALL_CONSTRAINT)
> +#define PV_TYPE_CONSTRAINT_STR		PV_STRINGIFY(PV_TYPE_CONSTRAINT)
> +#define PV_CLBR_CONSTRAINT_STR		PV_STRINGIFY(PV_CLBR_CONSTRAINT)
> +
> +#define PV_CALL_STR			"call *" PV_CALL_CONSTRAINT_STR ";"
> +
> +#define PV_INPUT_CONSTRAINTS(op, clobber)				\
> +	[PV_TYPE_CONSTRAINT] "i" (PARAVIRT_PATCH(op)),			\
> +	[PV_CALL_CONSTRAINT] "i" (&(op)),				\
> +	[PV_CLBR_CONSTRAINT] "i" (clobber)
> +
> +#define PV_SITE(insn_string)						\
> +	_PV_SITE(insn_string, PV_TYPE_CONSTRAINT_STR, PV_CLBR_CONSTRAINT_STR)
> +
> +#define PV_ALT_SITE(oldinstr, newinstr)					\
> +	_PV_ALT_SITE(oldinstr, newinstr, PV_TYPE_CONSTRAINT_STR,	\
> +		     PV_CLBR_CONSTRAINT_STR)
>  
>  /*
>   * These macros are intended to wrap calls through one of the paravirt
> @@ -525,25 +531,24 @@ int paravirt_disable_iospace(void);
>  
>  #define ____PVOP_CALL(rettype, op, clbr, call_clbr, extra_clbr,		\
>  		      pre, post, ...)					\
> -	({								\
> -		rettype __ret;						\
> -		PVOP_CALL_ARGS;						\
> -		PVOP_TEST_NULL(op);					\
> +({									\
> +	rettype __ret;							\
> +	PVOP_CALL_ARGS;							\
> +	PVOP_TEST_NULL(op);						\
>  		asm volatile(pre					\
> -			     paravirt_alt(PARAVIRT_CALL)		\
> +			     PV_SITE(PV_CALL_STR)			\
>  			     post					\
>  			     : call_clbr, ASM_CALL_CONSTRAINT		\
> -			     : paravirt_type(op),			\
> -			       paravirt_clobber(clbr),			\
> +			     : PV_INPUT_CONSTRAINTS(op, clbr),		\
>  			       ##__VA_ARGS__				\
>  			     : "memory", "cc" extra_clbr);		\
> -		if (IS_ENABLED(CONFIG_X86_32) &&			\
> -		    sizeof(rettype) > sizeof(unsigned long))		\
> -			__ret = (rettype)((((u64)__edx) << 32) | __eax);\
> -		else							\
> -			__ret = (rettype)(__eax & PVOP_RETMASK(rettype));\
> -		__ret;							\
> -	})

<---- newline here.

> +	if (IS_ENABLED(CONFIG_X86_32) &&				\
> +	    sizeof(rettype) > sizeof(unsigned long))			\
> +		__ret = (rettype)((((u64)__edx) << 32) | __eax);	\
> +	else								\
> +		__ret = (rettype)(__eax & PVOP_RETMASK(rettype));	\
> +	__ret;								\
> +})
-- 
Regards/Gruss,
    Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

  parent reply	other threads:[~2017-11-22 20:46 UTC|newest]

Thread overview: 175+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-04 15:58 [PATCH 00/13] x86/paravirt: Make pv ops code generation more closely match reality Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 01/13] x86/paravirt: remove wbinvd() paravirt interface Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58   ` Josh Poimboeuf
2017-10-24 13:17   ` Juergen Gross
2017-10-24 13:17   ` Juergen Gross
2017-10-24 13:17   ` Juergen Gross
2017-11-17 14:39   ` Borislav Petkov
2017-11-17 14:39   ` Borislav Petkov
2017-11-17 14:39   ` Borislav Petkov
2017-10-04 15:58 ` [PATCH 02/13] x86/paravirt: Fix output constraint macro names Josh Poimboeuf
2017-10-25  9:33   ` Juergen Gross
2017-10-25  9:33   ` Juergen Gross
2017-11-16 20:50     ` Josh Poimboeuf
2017-11-16 20:50     ` Josh Poimboeuf
2017-11-16 20:50       ` Josh Poimboeuf
2017-11-17  6:55       ` Juergen Gross
2017-11-17  6:55         ` Juergen Gross
2017-11-17  6:55       ` Juergen Gross
2017-10-25  9:33   ` Juergen Gross
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 03/13] x86/paravirt: Convert native patch assembly code strings to macros Josh Poimboeuf
2017-10-04 15:58   ` Josh Poimboeuf
2017-10-25  9:46   ` Juergen Gross
2017-10-25  9:46   ` Juergen Gross
2017-10-25  9:46   ` Juergen Gross
2017-11-16 21:04     ` Josh Poimboeuf
2017-11-16 21:04     ` Josh Poimboeuf
2017-11-16 21:04       ` Josh Poimboeuf
2017-11-17 18:07   ` Borislav Petkov
2017-11-17 18:07   ` Borislav Petkov
2017-11-17 18:07     ` Borislav Petkov
2017-11-17 19:10     ` Juergen Gross
2017-11-17 19:10     ` Juergen Gross
2017-11-17 19:10       ` Juergen Gross
2017-11-17 19:42       ` Josh Poimboeuf
2017-11-17 19:42         ` Josh Poimboeuf
2017-11-18 10:20         ` Juergen Gross
2017-11-18 10:20           ` Juergen Gross
2017-11-18 13:17           ` Josh Poimboeuf
2017-11-18 13:17             ` Josh Poimboeuf
2017-11-18 13:17           ` Josh Poimboeuf
2017-11-18 10:20         ` Juergen Gross
2017-11-17 19:42       ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 04/13] x86/paravirt: Convert DEF_NATIVE macro to GCC extended asm syntax Josh Poimboeuf
2017-10-25 10:03   ` Juergen Gross
2017-10-25 10:03   ` Juergen Gross
2017-10-25 10:03   ` Juergen Gross
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 05/13] x86/paravirt: Move paravirt asm macros to paravirt-asm.h Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58   ` Josh Poimboeuf
2017-10-25 10:32   ` Juergen Gross
2017-10-25 10:32   ` Juergen Gross
2017-10-25 10:32   ` Juergen Gross
2017-10-04 15:58 ` [PATCH 06/13] x86/paravirt: Clean up paravirt-asm.h Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-25 10:59   ` Juergen Gross
2017-10-25 10:59   ` Juergen Gross
2017-10-25 10:59   ` Juergen Gross
2017-10-04 15:58 ` [PATCH 07/13] x86/paravirt: Simplify ____PVOP_CALL() Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58   ` Josh Poimboeuf
2017-10-25 11:01   ` Juergen Gross
2017-10-25 11:01   ` Juergen Gross
2017-10-25 11:01   ` Juergen Gross
2017-11-22 16:35   ` Borislav Petkov
2017-11-22 16:35   ` Borislav Petkov
2017-11-22 16:35   ` Borislav Petkov
2017-10-04 15:58 ` [PATCH 08/13] x86/paravirt: Clean up paravirt_types.h Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-25 11:08   ` Juergen Gross
2017-10-25 11:08     ` Juergen Gross
2017-10-25 11:08   ` Juergen Gross
2017-11-22 20:46   ` Borislav Petkov
2017-11-22 20:46   ` Borislav Petkov [this message]
2017-11-22 20:46   ` Borislav Petkov
2017-10-04 15:58 ` [PATCH 09/13] x86/asm: Convert ALTERNATIVE*() assembler macros to preprocessor macros Josh Poimboeuf
2017-10-04 15:58   ` Josh Poimboeuf
2017-10-25 11:14   ` Juergen Gross
2017-10-25 11:14   ` Juergen Gross
2017-10-25 11:14     ` Juergen Gross
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 10/13] x86/alternative: Support indirect call replacement Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-25 11:25   ` Juergen Gross
2017-10-25 11:25   ` Juergen Gross
2017-10-25 11:25   ` Juergen Gross
2017-11-16 21:19     ` Josh Poimboeuf
2017-11-16 21:19     ` Josh Poimboeuf
2017-11-16 21:19       ` Josh Poimboeuf
2017-11-17  5:46       ` Juergen Gross
2017-11-17  5:46       ` Juergen Gross
2017-11-17  5:46         ` Juergen Gross
2017-11-17 19:52   ` H. Peter Anvin
2017-11-17 19:52     ` H. Peter Anvin
2017-11-17 19:52   ` H. Peter Anvin
2017-10-04 15:58 ` [PATCH 11/13] x86/paravirt: Add paravirt alternatives infrastructure Josh Poimboeuf
2017-10-05 20:35   ` Boris Ostrovsky
2017-10-05 20:35     ` Boris Ostrovsky
2017-10-06 14:32     ` Josh Poimboeuf
2017-10-06 15:29       ` Boris Ostrovsky
2017-10-06 15:29         ` Boris Ostrovsky
2017-10-06 16:30         ` Josh Poimboeuf
2017-10-06 16:30         ` Josh Poimboeuf
2017-10-06 16:30         ` Josh Poimboeuf
2017-10-06 15:29       ` Boris Ostrovsky
2017-10-12 19:11       ` Boris Ostrovsky
2017-10-12 19:11       ` Boris Ostrovsky
2017-10-12 19:11         ` Boris Ostrovsky
2017-10-12 19:27         ` Andrew Cooper
2017-10-12 19:27         ` [Xen-devel] " Andrew Cooper
2017-10-12 19:27           ` Andrew Cooper
2017-10-12 19:53           ` Boris Ostrovsky
2017-10-12 19:53           ` [Xen-devel] " Boris Ostrovsky
2017-10-12 19:53             ` Boris Ostrovsky
2017-10-16 18:18             ` Boris Ostrovsky
2017-10-16 18:18             ` [Xen-devel] " Boris Ostrovsky
2017-10-16 18:18               ` Boris Ostrovsky
2017-10-17  5:24               ` Josh Poimboeuf
2017-10-17  5:24               ` Josh Poimboeuf
2017-10-17 13:58                 ` Boris Ostrovsky
2017-10-17 13:58                   ` Boris Ostrovsky
2017-10-17 14:36                   ` Josh Poimboeuf
2017-10-17 14:36                   ` [Xen-devel] " Josh Poimboeuf
2017-10-17 14:36                   ` Josh Poimboeuf
2017-10-17 15:36                     ` Boris Ostrovsky
2017-10-17 15:36                     ` [Xen-devel] " Boris Ostrovsky
2017-10-17 15:36                       ` Boris Ostrovsky
2017-10-17 20:17                       ` Josh Poimboeuf
2017-10-17 20:17                       ` Josh Poimboeuf
2017-10-17 20:36                         ` Boris Ostrovsky
2017-10-17 20:36                           ` Boris Ostrovsky
2017-10-17 20:50                           ` Josh Poimboeuf
2017-10-17 20:50                           ` [Xen-devel] " Josh Poimboeuf
2017-10-17 20:59                             ` Boris Ostrovsky
2017-10-17 20:59                               ` Boris Ostrovsky
2017-10-17 21:03                               ` Josh Poimboeuf
2017-10-17 21:03                               ` [Xen-devel] " Josh Poimboeuf
2017-10-17 21:03                               ` Josh Poimboeuf
2017-10-17 20:59                             ` Boris Ostrovsky
2017-10-17 20:50                           ` [Xen-devel] " Josh Poimboeuf
2017-10-17 20:36                         ` Boris Ostrovsky
2017-10-17 20:17                       ` Josh Poimboeuf
2017-10-17 13:58                 ` Boris Ostrovsky
2017-10-17  5:24               ` Josh Poimboeuf
2017-10-17 13:10               ` [Xen-devel] " Brian Gerst
2017-10-17 13:10               ` Brian Gerst
2017-10-17 13:10               ` [Xen-devel] " Brian Gerst
2017-10-17 14:05                 ` Boris Ostrovsky
2017-10-17 14:05                 ` [Xen-devel] " Boris Ostrovsky
2017-10-17 14:05                   ` Boris Ostrovsky
2017-10-06 14:32     ` Josh Poimboeuf
2017-10-06 14:32     ` Josh Poimboeuf
2017-10-05 20:35   ` Boris Ostrovsky
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 12/13] objtool: Add support for new .pv_altinstructions section Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` [PATCH 13/13] x86/paravirt: Convert natively patched pv ops to use paravirt alternatives Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-04 15:58 ` Josh Poimboeuf
2017-10-06  7:35 ` [Xen-devel] [PATCH 00/13] x86/paravirt: Make pv ops code generation more closely match reality Vitaly Kuznetsov
2017-10-06  7:35 ` Vitaly Kuznetsov
2017-10-06 14:36   ` Josh Poimboeuf
2017-10-06 14:36   ` Josh Poimboeuf
2017-10-06 14:36   ` [Xen-devel] " Josh Poimboeuf
2017-10-06  7:35 ` Vitaly Kuznetsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171122204610.mtpjea2wbeuey5mp@pd.tnic \
    --to=bp@alien8.de \
    --cc=akataria@vmware.com \
    --cc=alexander.levin@verizon.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=chrisw@sous-sol.org \
    --cc=efault@gmx.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jpoimboe@redhat.com \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rusty@rustcorp.com.au \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.