mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sohil Mehta <sohil.mehta@intel.com>
To: Dave Hansen <dave.hansen@linux.intel.com>,
	<linux-kernel@vger.kernel.org>
Cc: David Binderman <dcb314@hotmail.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	<x86@kernel.org>
Subject: Re: [PATCH] x86/mm: Simplify redundant overlap calculation
Date: Tue, 23 Jan 2024 11:28:26 -0800	[thread overview]
Message-ID: <7f4729cd-da86-4198-a2be-1c12a5513eb3@intel.com> (raw)
In-Reply-To: <20240123163623.1342917-1-dave.hansen@linux.intel.com>

On 1/23/2024 8:36 AM, Dave Hansen wrote:
> There have been a couple of reports that the two sides of the
> overlaps() calculation are redundant.  I spent way too much time
> looking at this, but I became convinced that they are redundant
> when a little test program of mine produced identical disassembly
> for both versions of the check.
> 
> Remove the second condition.  It is exactly the same as the first.
> 
> Fixes: 91ee8f5c1f50 ("x86/mm/cpa: Allow range check for static protections")
> Reported-by: David Binderman <dcb314@hotmail.com>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: x86@kernel.org
> ---
>  arch/x86/mm/pat/set_memory.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 

Reviewed-by: Sohil Mehta <sohil.mehta@intel.com>

> diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c
> index e9b448d1b1b70..fdc00516c0b54 100644
> --- a/arch/x86/mm/pat/set_memory.c
> +++ b/arch/x86/mm/pat/set_memory.c
> @@ -435,8 +435,7 @@ static void cpa_flush(struct cpa_data *data, int cache)
>  static bool overlaps(unsigned long r1_start, unsigned long r1_end,
>  		     unsigned long r2_start, unsigned long r2_end)
>  {
> -	return (r1_start <= r2_end && r1_end >= r2_start) ||
> -		(r2_start <= r1_end && r2_end >= r1_start);
> +	return (r1_start <= r2_end && r1_end >= r2_start);
>  }
>  
>  #ifdef CONFIG_PCI_BIOS


      parent reply	other threads:[~2024-01-23 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-23 16:36 Dave Hansen
2024-01-23 16:47 ` Dave Hansen
2024-01-23 16:54 ` David Binderman
2024-01-23 17:00   ` Dave Hansen
2024-01-23 19:19     ` Sohil Mehta
2024-01-23 19:28 ` Sohil Mehta [this message]

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=7f4729cd-da86-4198-a2be-1c12a5513eb3@intel.com \
    --to=sohil.mehta@intel.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dcb314@hotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®