All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Jan Beulich <JBeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>,
	mingo@elte.hu, xen-devel <xen-devel@lists.xenproject.org>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	sds@tycho.nsa.gov, linux-kernel@vger.kernel.org, hpa@zytor.com
Subject: Re: [PATCH 1/2] x86: consider effective protection attributes in W+X check
Date: Thu, 14 Dec 2017 15:17:38 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1712141516240.4998@nanos> (raw)
In-Reply-To: <5A32959902000078001975D6@prv-mh.provo.novell.com>

On Thu, 14 Dec 2017, Jan Beulich wrote:
> >>> On 14.12.17 at 15:04, <jgross@suse.com> wrote:
> > On 12/12/17 11:31, Jan Beulich wrote:
> >> @@ -335,42 +346,45 @@ static inline bool kasan_page_table(stru
> >>  
> >>  #if PTRS_PER_PMD > 1
> >>  
> >> -static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, unsigned long P)
> >> +static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr,
> >> +			   pgprotval_t eff_in, unsigned long P)
> >>  {
> >>  	int i;
> >>  	pmd_t *start, *pmd_start;
> >> -	pgprotval_t prot;
> >> +	pgprotval_t prot, eff;
> >>  
> >>  	pmd_start = start = (pmd_t *)pud_page_vaddr(addr);
> >>  	for (i = 0; i < PTRS_PER_PMD; i++) {
> >>  		st->current_address = normalize_addr(P + i * PMD_LEVEL_MULT);
> >>  		if (!pmd_none(*start)) {
> >> +			prot = pmd_flags(*start);
> >> +			eff = effective_prot(eff_in, prot);
> >>  			if (pmd_large(*start) || !pmd_present(*start)) {
> >> -				prot = pmd_flags(*start);
> >> -				note_page(m, st, __pgprot(prot), 4);
> >> +				note_page(m, st, __pgprot(prot), eff, 4);
> >>  			} else if (!kasan_page_table(m, st, pmd_start)) {
> >> -				walk_pte_level(m, st, *start,
> >> +				walk_pte_level(m, st, *start, eff,
> >>  					       P + i * PMD_LEVEL_MULT);
> >>  			}
> > 
> > You can drop the braces for both cases. Applies to similar
> > constructs below, too.
> 
> I did consider that, but decided against to allow the patch to show
> more clearly what it is that is actually being changed.
> 
> > With that fixed you can add my:
> > 
> > Reviewed-by: Juergen Gross <jgross@suse.com>
> 
> Thanks. I'd like to wait for the x86 maintainer's opinion, and hence
> won't add your R-b unless you tell me that's fine either way, or
> unless they too would prefer resulting code cleanliness over patch
> readability.

If you remove the braces the code readability degrades because it's not a
single line statement.

Thanks,

	tglx

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: Jan Beulich <JBeulich@suse.com>
Cc: Juergen Gross <jgross@suse.com>,
	linux-kernel@vger.kernel.org, hpa@zytor.com,
	xen-devel <xen-devel@lists.xenproject.org>,
	mingo@elte.hu, sds@tycho.nsa.gov,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH 1/2] x86: consider effective protection attributes in W+X check
Date: Thu, 14 Dec 2017 15:17:38 +0100 (CET)	[thread overview]
Message-ID: <alpine.DEB.2.20.1712141516240.4998@nanos> (raw)
In-Reply-To: <5A32959902000078001975D6@prv-mh.provo.novell.com>

On Thu, 14 Dec 2017, Jan Beulich wrote:
> >>> On 14.12.17 at 15:04, <jgross@suse.com> wrote:
> > On 12/12/17 11:31, Jan Beulich wrote:
> >> @@ -335,42 +346,45 @@ static inline bool kasan_page_table(stru
> >>  
> >>  #if PTRS_PER_PMD > 1
> >>  
> >> -static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr, unsigned long P)
> >> +static void walk_pmd_level(struct seq_file *m, struct pg_state *st, pud_t addr,
> >> +			   pgprotval_t eff_in, unsigned long P)
> >>  {
> >>  	int i;
> >>  	pmd_t *start, *pmd_start;
> >> -	pgprotval_t prot;
> >> +	pgprotval_t prot, eff;
> >>  
> >>  	pmd_start = start = (pmd_t *)pud_page_vaddr(addr);
> >>  	for (i = 0; i < PTRS_PER_PMD; i++) {
> >>  		st->current_address = normalize_addr(P + i * PMD_LEVEL_MULT);
> >>  		if (!pmd_none(*start)) {
> >> +			prot = pmd_flags(*start);
> >> +			eff = effective_prot(eff_in, prot);
> >>  			if (pmd_large(*start) || !pmd_present(*start)) {
> >> -				prot = pmd_flags(*start);
> >> -				note_page(m, st, __pgprot(prot), 4);
> >> +				note_page(m, st, __pgprot(prot), eff, 4);
> >>  			} else if (!kasan_page_table(m, st, pmd_start)) {
> >> -				walk_pte_level(m, st, *start,
> >> +				walk_pte_level(m, st, *start, eff,
> >>  					       P + i * PMD_LEVEL_MULT);
> >>  			}
> > 
> > You can drop the braces for both cases. Applies to similar
> > constructs below, too.
> 
> I did consider that, but decided against to allow the patch to show
> more clearly what it is that is actually being changed.
> 
> > With that fixed you can add my:
> > 
> > Reviewed-by: Juergen Gross <jgross@suse.com>
> 
> Thanks. I'd like to wait for the x86 maintainer's opinion, and hence
> won't add your R-b unless you tell me that's fine either way, or
> unless they too would prefer resulting code cleanliness over patch
> readability.

If you remove the braces the code readability degrades because it's not a
single line statement.

Thanks,

	tglx

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2017-12-14 14:18 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-12 10:24 [PATCH 0/2] x86: deal with remaining W+X pages on Xen Jan Beulich
2017-12-12 10:31 ` [PATCH 1/2] x86: consider effective protection attributes in W+X check Jan Beulich
2017-12-12 10:36   ` Ingo Molnar
2017-12-12 10:36   ` Ingo Molnar
2017-12-12 10:43     ` Jan Beulich
2017-12-12 10:43     ` Jan Beulich
2017-12-12 10:31 ` Jan Beulich
2017-12-12 10:32 ` [PATCH 2/2] x86-64/Xen: eliminate W+X mappings Jan Beulich
2017-12-12 10:38   ` Ingo Molnar
2017-12-12 10:38   ` Ingo Molnar
2017-12-12 10:48     ` Jan Beulich
2017-12-12 10:48     ` Jan Beulich
2017-12-12 10:54       ` Ingo Molnar
2017-12-12 10:54       ` Ingo Molnar
     [not found]     ` <5A2FC2280200007800196BB8@suse.com>
2017-12-12 13:14       ` Juergen Gross
2017-12-12 13:14       ` Juergen Gross
2017-12-18 11:11   ` [PATCH v2] " Jan Beulich
2017-12-18 12:28     ` Ingo Molnar
2017-12-18 15:52       ` Joe Perches
2017-12-18 15:52       ` Joe Perches
2017-12-18 12:28     ` Ingo Molnar
2017-12-18 11:11   ` Jan Beulich
2017-12-18 16:37   ` [PATCH v3] " Jan Beulich
2017-12-18 16:37   ` Jan Beulich
2017-12-12 10:32 ` [PATCH 2/2] " Jan Beulich
     [not found] ` <5A2FBE0A0200007800196B4F@suse.com>
2017-12-14 14:04   ` [PATCH 1/2] x86: consider effective protection attributes in W+X check Juergen Gross
2017-12-14 14:12     ` Thomas Gleixner
2017-12-14 14:12     ` Thomas Gleixner
2017-12-14 14:15     ` Jan Beulich
2017-12-14 14:17       ` Thomas Gleixner [this message]
2017-12-14 14:17         ` Thomas Gleixner
2017-12-14 14:21       ` Juergen Gross
2017-12-14 14:21       ` Juergen Gross
2017-12-14 14:15     ` Jan Beulich
2017-12-14 14:04   ` Juergen Gross

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=alpine.DEB.2.20.1712141516240.4998@nanos \
    --to=tglx@linutronix.de \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=sds@tycho.nsa.gov \
    --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.