linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Christian Kujau <lists@nerdbynature.de>
Cc: Juergen Gross <jgross@suse.com>,
	Michael Kelley <mikelley@microsoft.com>,
	Borislav Petkov <bp@alien8.de>,
	linux-kernel@vger.kernel.org,
	Greg KH <gregkh@linuxfoundation.org>,
	Linux regressions mailing list <regressions@lists.linux.dev>
Subject: Re: External USB disks not recognized with v6.1.8 when using Xen
Date: Thu, 2 Feb 2023 12:24:30 -0800	[thread overview]
Message-ID: <CAHk-=wg1yXaX+Ut4uctf7x1WrZ4WW9hjSCr1VACwZtkZT9frFw@mail.gmail.com> (raw)
In-Reply-To: <f02c49da-0377-97b9-9438-9e0ddbfbcc6d@nerdbynature.de>

On Thu, Feb 2, 2023 at 3:38 AM Christian Kujau <lists@nerdbynature.de> wrote:
>
> On Wed, 1 Feb 2023, Juergen Gross wrote:
> > On 31.01.23 23:50, Christian Kujau wrote:
> > > [Leaving the full quote below for reference and adding more appropriate
> > > people.]
> > >
> > > After a far too long round of git-bisect I narrowed it down to:
> > >
> > >    c1c59538337ab6d45700cb4a1c9725e67f59bc6e is the first bad commit
> > >
> > >      x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case
> > >      commit 90b926e68f500844dff16b5bcea178dc55cf580a upstream.
> > >
> > > And indeed, reverting this single commit from v6.1.8 (stable) makes the
> > > disks appear again.
>
> This also happens on mainline, not only in stable. Reverting this patch
> from 6.2-rc6 makes the disks appear again.

I think the patch is simply wrong and should be reverted.

The way hardware works, MTRR_TYPE_INVALID implies UC-, not WB.

So that commit 90b926e68f50 ("x86/pat: Fix pat_x_mtrr_type() for MTRR
disabled case") is simply wrong to say "disabled means the same as
WB",.

That said, I think mtrr_type_lookup() is wrong too. It has two bugs

 (a) it basically returns the wrong mtrr type for the "not enabled" conditions

 (b) it doesn't set the "uniform" bit for said conditions, which then
causes problems for callers - the hugepage case in particular only
checks for that MTRR_TYPE_INVALID case because of this.

 (c) it sets is_uniform wrongly for the fixed mtrr case, but I guess
the only thing that cares is largepage, so it works

and I think the !CONFIG_MTRR case has the same issue.

I'm not convinced it *ever* makes sense for mtrr_type_lookup() to
return MTRR_TYPE_INVALID (it makes sense for the helper functions to
do so to let the code know to look at other mtrrs, but not the final
lookup).

And at a minimum, the !MTRR_STATE_MTRR_ENABLED case seems very wrong -
if mtrr is disabled, it should return 'def_type', no?>

So I think that commit should be reverted as broken, and then people
should *maybe* look at something like this (intentionally whitespace
damaged, and people should *really* think about what the
MTRR_TYPE_INVALID case should be - returning UC- is probably what is
closest to "this is what the hardware does", but maybe doesn't make
sense for the largepage case, which might as well just always use
largepages in that case?)

   --- a/arch/x86/include/asm/mtrr.h
   +++ b/arch/x86/include/asm/mtrr.h
   @@ -53,7 +53,8 @@ static inline u8 mtrr_type_lookup(..
        /*
         * Return no-MTRRs:
         */
   -    return MTRR_TYPE_INVALID;
   +    *uniform = 1;
   +    return MTRR_TYPE_INVALID; /* ??? */
    }
    #define mtrr_save_fixed_ranges(arg) do {} while (0)
    #define mtrr_save_state() do {} while (0)
   --- a/arch/x86/kernel/cpu/mtrr/generic.c
   +++ b/arch/x86/kernel/cpu/mtrr/generic.c
   @@ -261,11 +261,13 @@ u8 mtrr_type_lookup(..
        /* Make end inclusive instead of exclusive */
        end--;

   +    type = MTRR_TYPE_INVALID; /* ??? */
        if (!mtrr_state_set)
   -            return MTRR_TYPE_INVALID;
   +            goto out;

   +    type = mtrr_state.def_type;
        if (!(mtrr_state.enabled & MTRR_STATE_MTRR_ENABLED))
   -            return MTRR_TYPE_INVALID;
   +            goto out;

        /*
         * Look up the fixed ranges first, which take priority over

But note how I think the !MTRR_STATE_MTRR_ENABLED case really should
return the default mtrr type, and that looks fairly unambiguous to me.

Hmm?

            Linus

  reply	other threads:[~2023-02-02 20:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-30  3:46 External USB disks not recognized with v6.1.8 when using Xen Christian Kujau
2023-01-30  5:17 ` Greg KH
2023-01-30 12:01 ` Linux kernel regression tracking (#adding)
2023-01-31 22:50   ` Christian Kujau
2023-02-01  8:14     ` Juergen Gross
2023-02-01  9:37       ` Christian Kujau
2023-02-02 11:38       ` Christian Kujau
2023-02-02 20:24         ` Linus Torvalds [this message]
2023-02-03 16:50           ` Christian Kujau
2023-02-03 17:29             ` Christian Kujau
2023-02-05 13:20           ` Borislav Petkov
2023-02-05 17:17             ` Christian Kujau
2023-02-05 20:21             ` Linus Torvalds
2023-02-06  6:33               ` Juergen Gross
2023-02-06  9:54                 ` Juergen Gross
2023-02-06  9:43               ` Borislav Petkov
2023-02-05 10:40     ` Linux kernel regression tracking (#update)
2023-02-14  9:35 ` [tip: x86/urgent] x86/mtrr: Revert 90b926e68f50 ("x86/pat: Fix pat_x_mtrr_type() for MTRR disabled case") tip-bot2 for Juergen Gross
2023-02-18  9:47   ` Christian Kujau
2023-02-18  9:59     ` Borislav Petkov
2023-05-08 13:41     ` [tip: x86/cleanups] Documentation/process: Explain when tip branches get merged into mainline tip-bot2 for Christian Kujau
2023-05-15 15:28     ` tip-bot2 for Christian Kujau

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='CAHk-=wg1yXaX+Ut4uctf7x1WrZ4WW9hjSCr1VACwZtkZT9frFw@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lists@nerdbynature.de \
    --cc=mikelley@microsoft.com \
    --cc=regressions@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).