Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1226577 > unrolled thread
| Started by | Andy Lutomirski <luto@kernel.org> |
|---|---|
| First post | 2015-09-17 01:40 +0200 |
| Last post | 2015-09-17 17:20 +0200 |
| Articles | 20 on this page of 25 — 10 participants |
Back to article view | Back to linux.kernel
[PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andy Lutomirski <luto@kernel.org> - 2015-09-17 01:40 +0200
[PATCH 3/3] x86/paravirt: Make "unsafe" MSR accesses unsafe even if PARAVIRT=y Andy Lutomirski <luto@kernel.org> - 2015-09-17 01:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Ingo Molnar <mingo@kernel.org> - 2015-09-17 09:20 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Borislav Petkov <bp@alien8.de> - 2015-09-17 11:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops "H. Peter Anvin" <hpa@zytor.com> - 2015-09-17 13:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 13:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Borislav Petkov <bp@alien8.de> - 2015-09-17 17:30 +0200
Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Borislav Petkov <bp@alien8.de> - 2015-09-17 17:40 +0200
Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andrew Cooper <andrew.cooper3@citrix.com> - 2015-09-17 17:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Arjan van de Ven <arjan@linux.intel.com> - 2015-09-17 17:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 17:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Arjan van de Ven <arjan@linux.intel.com> - 2015-09-17 17:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 17:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andy Lutomirski <luto@amacapital.net> - 2015-09-17 17:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Ingo Molnar <mingo@kernel.org> - 2015-09-17 19:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andy Lutomirski <luto@amacapital.net> - 2015-09-17 21:00 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Peter Zijlstra <peterz@infradead.org> - 2015-09-17 11:10 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 13:50 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Peter Zijlstra <peterz@infradead.org> - 2015-09-17 14:40 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andy Lutomirski <luto@amacapital.net> - 2015-09-17 17:20 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Peter Zijlstra <peterz@infradead.org> - 2015-09-17 17:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andy Lutomirski <luto@amacapital.net> - 2015-09-17 17:30 +0200
Re: [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Paolo Bonzini <pbonzini@redhat.com> - 2015-09-17 17:40 +0200
Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Andrew Cooper <andrew.cooper3@citrix.com> - 2015-09-17 11:20 +0200
Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops Boris Ostrovsky <boris.ostrovsky@oracle.com> - 2015-09-17 17:20 +0200
Page 1 of 2 [1] 2 Next page →
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2015-09-17 01:40 +0200 |
| Subject | [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops |
| Message-ID | <q9usW-2um-9@gated-at.bofh.it> |
Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently
turns all rdmsr and wrmsr operations into the safe variants without
any checks that the operations actually succeed.
This is IMO awful: it papers over bugs. In particular, KVM gueests
might be unwittingly depending on this behavior because
CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not
aware of any such problems, but applying this series would be a good
way to shake them out.
Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n
and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen
maintainers are welcome to make a similar change on top of this.
Since there's plenty of time before the next merge window, I think
we should apply and fix anything that breaks.
Doing this is probably a prerequisite to sanely decoupling
CONFIG_KVM_GUEST and CONFIG_PARAVIRT, which would probably make
Arjan and the rest of the Clear Containers people happy :)
Andy Lutomirski (3):
x86/paravirt: Add _safe to the read_msr and write_msr PV hooks
x86/paravirt: Add paravirt_{read,write}_msr
x86/paravirt: Make "unsafe" MSR accesses unsafe even if PARAVIRT=y
arch/x86/include/asm/paravirt.h | 45 +++++++++++++++++++++--------------
arch/x86/include/asm/paravirt_types.h | 12 +++++++---
arch/x86/kernel/paravirt.c | 6 +++--
arch/x86/xen/enlighten.c | 27 +++++++++++++++++++--
4 files changed, 65 insertions(+), 25 deletions(-)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2015-09-17 01:40 +0200 |
| Subject | [PATCH 3/3] x86/paravirt: Make "unsafe" MSR accesses unsafe even if PARAVIRT=y |
| Message-ID | <q9usW-2um-21@gated-at.bofh.it> |
| In reply to | #1226577 |
Enabling CONFIG_PARAVIRT had an unintended side effect: rdmsr turned
into rdmsr_safe and wrmsr turned into wrmsr_safe, even on bare
metal. Undo that by using the new unsafe paravirt MSR hooks.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/include/asm/paravirt.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
index e6569a3b0a37..f61975a3ccfd 100644
--- a/arch/x86/include/asm/paravirt.h
+++ b/arch/x86/include/asm/paravirt.h
@@ -145,24 +145,21 @@ static inline int paravirt_write_msr_safe(unsigned msr,
return PVOP_CALL3(int, pv_cpu_ops.write_msr_safe, msr, low, high);
}
-/* These should all do BUG_ON(_err), but our headers are too tangled. */
#define rdmsr(msr, val1, val2) \
do { \
- int _err; \
- u64 _l = paravirt_read_msr_safe(msr, &_err); \
+ u64 _l = paravirt_read_msr(msr); \
val1 = (u32)_l; \
val2 = _l >> 32; \
} while (0)
#define wrmsr(msr, val1, val2) \
do { \
- paravirt_write_msr_safe(msr, val1, val2); \
+ paravirt_write_msr(msr, val1, val2); \
} while (0)
#define rdmsrl(msr, val) \
do { \
- int _err; \
- val = paravirt_read_msr_safe(msr, &_err); \
+ val = paravirt_read_msr(msr); \
} while (0)
static inline void wrmsrl(unsigned msr, u64 val)
--
2.4.3
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-09-17 09:20 +0200 |
| Message-ID | <q9BE5-4IO-7@gated-at.bofh.it> |
| In reply to | #1226577 |
* Andy Lutomirski <luto@kernel.org> wrote: > Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently > turns all rdmsr and wrmsr operations into the safe variants without > any checks that the operations actually succeed. > > This is IMO awful: it papers over bugs. In particular, KVM gueests > might be unwittingly depending on this behavior because > CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not > aware of any such problems, but applying this series would be a good > way to shake them out. > > Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n > and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen > maintainers are welcome to make a similar change on top of this. > > Since there's plenty of time before the next merge window, I think > we should apply and fix anything that breaks. No, I think we should at most generate a warning instead, and not crash the kernel via rdmsr()! Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I checked Ubuntu and Fedora), so we are potentially exposing a lot of users to problems. Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are non-critical and returning the 'safe' result is much better than crashing or hanging the bootup. ( We should double check that rdmsr()/wrmsr() results are never left uninitialized, but are set to zero or so, for cases where the return code is not checked. ) Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2015-09-17 11:40 +0200 |
| Message-ID | <q9DPC-7XC-41@gated-at.bofh.it> |
| In reply to | #1226705 |
On Thu, Sep 17, 2015 at 09:19:20AM +0200, Ingo Molnar wrote:
> Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I checked Ubuntu and
> Fedora), so we are potentially exposing a lot of users to problems.
+ SUSE.
> Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are
> non-critical and returning the 'safe' result is much better than crashing or
> hanging the bootup.
... and prepending all MSR accesses with feature/CPUID checks is probably almost
impossible.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | "H. Peter Anvin" <hpa@zytor.com> |
|---|---|
| Date | 2015-09-17 13:30 +0200 |
| Message-ID | <q9Fy1-24Q-7@gated-at.bofh.it> |
| In reply to | #1226810 |
However, the difference between one CONFIG and another is quite frankly crazy. We should explicitly use the safe versions where this is appropriate, and then yes, we should do this. Yet another reason the paravirt code is batshit crazy. On September 17, 2015 2:31:34 AM PDT, Borislav Petkov <bp@alien8.de> wrote: >On Thu, Sep 17, 2015 at 09:19:20AM +0200, Ingo Molnar wrote: >> Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I >checked Ubuntu and >> Fedora), so we are potentially exposing a lot of users to problems. > >+ SUSE. > >> Crashing the bootup on an unknown MSR is bad. Many MSR reads and >writes are >> non-critical and returning the 'safe' result is much better than >crashing or >> hanging the bootup. > >... and prepending all MSR accesses with feature/CPUID checks is >probably almost >impossible. -- Sent from my Android device with K-9 Mail. Please excuse my brevity. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-09-17 13:40 +0200 |
| Message-ID | <q9FHH-2gj-5@gated-at.bofh.it> |
| In reply to | #1226810 |
On 17/09/2015 11:31, Borislav Petkov wrote: > >> > Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are >> > non-critical and returning the 'safe' result is much better than crashing or >> > hanging the bootup. > ... and prepending all MSR accesses with feature/CPUID checks is probably almost > impossible. That's not a big deal, that's what *_safe is for. The problem is that there are definitely some cases where the *_safe version is not being used. I agree with Ingo that we should start with a WARN. For example: - give the read_msr and write_msr hooks the same prototype as the safe variants - make the virt platforms always return "no error" for the unsafe variants (I understand if your first reaction is "ouch", but this effectively is already the current behavior) - change rdmsr/wrmsr/rdmsrl/wrmsrl to WARN if the read_msr and write_msr hooks return an error Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2015-09-17 17:30 +0200 |
| Message-ID | <q9Jii-7CU-15@gated-at.bofh.it> |
| In reply to | #1226928 |
On Thu, Sep 17, 2015 at 01:39:26PM +0200, Paolo Bonzini wrote:
> That's not a big deal, that's what *_safe is for. The problem is that
> there are definitely some cases where the *_safe version is not being used.
I mean to do feature checks which assure you that those MSRs are
there so you don't need the safe variants. And that is not always
easy/possible.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Date | 2015-09-17 17:40 +0200 |
| Subject | Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops |
| Message-ID | <q9Js0-7OO-63@gated-at.bofh.it> |
| In reply to | #1227122 |
On Thu, Sep 17, 2015 at 04:32:53PM +0100, Andrew Cooper wrote:
> There are plenty of non-architectural MSRs in use which don't have
> feature bits.
That's exactly what the "possible" adjective was supposed to represent.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andrew Cooper <andrew.cooper3@citrix.com> |
|---|---|
| Date | 2015-09-17 17:40 +0200 |
| Subject | Re: [Xen-devel] [PATCH 0/3] x86/paravirt: Fix baremetal paravirt MSR ops |
| Message-ID | <q9Js0-7OO-65@gated-at.bofh.it> |
| In reply to | #1227122 |
On 17/09/15 16:27, Borislav Petkov wrote: > On Thu, Sep 17, 2015 at 01:39:26PM +0200, Paolo Bonzini wrote: >> That's not a big deal, that's what *_safe is for. The problem is that >> there are definitely some cases where the *_safe version is not being used. > I mean to do feature checks which assure you that those MSRs are > there so you don't need the safe variants. And that is not always > easy/possible. > There are plenty of non-architectural MSRs in use which don't have feature bits. Xen used to have problems booting when using the masking MSRs when booting virtualised. Nowadays it uses a cpu vendor check and _safe() probe to detect support. ~Andrew -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arjan van de Ven <arjan@linux.intel.com> |
|---|---|
| Date | 2015-09-17 17:30 +0200 |
| Message-ID | <q9Jii-7CU-7@gated-at.bofh.it> |
| In reply to | #1226705 |
> >> ( We should double check that rdmsr()/wrmsr() results are never left >> uninitialized, but are set to zero or so, for cases where the return code is not >> checked. ) > > It sure looks like native_read_msr_safe doesn't clear the output if > the rdmsr fails. I'd suggest to return some poison not just 0... less likely to get interesting surprises that are insane hard to debug/diagnose -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-09-17 17:30 +0200 |
| Message-ID | <q9Jii-7CU-19@gated-at.bofh.it> |
| In reply to | #1227118 |
On 17/09/2015 17:27, Arjan van de Ven wrote: >> >>> ( We should double check that rdmsr()/wrmsr() results are never left >>> uninitialized, but are set to zero or so, for cases where the >>> return code is not >>> checked. ) >> >> It sure looks like native_read_msr_safe doesn't clear the output if >> the rdmsr fails. > > I'd suggest to return some poison not just 0... What about 0 + WARN? Paolo > less likely to get interesting surprises that are insane hard to > debug/diagnose -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Arjan van de Ven <arjan@linux.intel.com> |
|---|---|
| Date | 2015-09-17 17:40 +0200 |
| Message-ID | <q9JrZ-7OO-41@gated-at.bofh.it> |
| In reply to | #1227123 |
On 9/17/2015 8:29 AM, Paolo Bonzini wrote: > > > On 17/09/2015 17:27, Arjan van de Ven wrote: >>> >>>> ( We should double check that rdmsr()/wrmsr() results are never left >>>> uninitialized, but are set to zero or so, for cases where the >>>> return code is not >>>> checked. ) >>> >>> It sure looks like native_read_msr_safe doesn't clear the output if >>> the rdmsr fails. >> >> I'd suggest to return some poison not just 0... > > What about 0 + WARN? why 0? 0xdeadbeef or any other pattern (even 0x3636363636) makes more sense (of course also WARN... but most folks don't read dmesg for WARNs) (it's the same thing we do for list or slab poison stuff) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-09-17 17:40 +0200 |
| Message-ID | <q9JrZ-7OO-45@gated-at.bofh.it> |
| In reply to | #1227132 |
On 17/09/2015 17:31, Arjan van de Ven wrote: >> >> What about 0 + WARN? > > why 0? > > 0xdeadbeef or any other pattern (even 0x3636363636) makes more sense (of > course also WARN... but most folks don't read dmesg for WARNs) > > (it's the same thing we do for list or slab poison stuff) Sorry, brain fart. That makes sense for the safe variants. It would require some auditing though. Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2015-09-17 17:30 +0200 |
| Message-ID | <q9Jii-7CU-9@gated-at.bofh.it> |
| In reply to | #1226705 |
On Thu, Sep 17, 2015 at 12:19 AM, Ingo Molnar <mingo@kernel.org> wrote: > > * Andy Lutomirski <luto@kernel.org> wrote: > >> Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently >> turns all rdmsr and wrmsr operations into the safe variants without >> any checks that the operations actually succeed. >> >> This is IMO awful: it papers over bugs. In particular, KVM gueests >> might be unwittingly depending on this behavior because >> CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not >> aware of any such problems, but applying this series would be a good >> way to shake them out. >> >> Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n >> and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen >> maintainers are welcome to make a similar change on top of this. >> >> Since there's plenty of time before the next merge window, I think >> we should apply and fix anything that breaks. > > No, I think we should at most generate a warning instead, and not crash the kernel > via rdmsr()! > > Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I checked Ubuntu and > Fedora), so we are potentially exposing a lot of users to problems. > > Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are > non-critical and returning the 'safe' result is much better than crashing or > hanging the bootup. > Should we do that for CONFIG_PARAVIRT=n, too? It would be straightforward to rig this up (temporarily?) on top of these patches. To keep bloat down, we might want to implement it in do_general_protection rather than sticking it in native_read_msr. wrmsr is a different beast, since we can fail due to writing the wrong value to an otherwise valid MSR. Given that MSR screwups can very easily be security holes, I'm not sure that warning and blindly continuing on an unchecked failed wrmsr is a good idea. In any event, I think it's nuts that CONFIG_PARAVIRT changes this behavior. We should pick something sane and stick with it. CONFIG_PARAVIRT=n appears to work just fine on bare metal in lots of deployments, especially pre-KVM. CONFIG_PARAVIRT=n also appears to work fine under KVM, and I use it frequently. > ( We should double check that rdmsr()/wrmsr() results are never left > uninitialized, but are set to zero or so, for cases where the return code is not > checked. ) It sure looks like native_read_msr_safe doesn't clear the output if the rdmsr fails. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Ingo Molnar <mingo@kernel.org> |
|---|---|
| Date | 2015-09-17 19:40 +0200 |
| Message-ID | <q9Lk7-286-45@gated-at.bofh.it> |
| In reply to | #1227120 |
* Andy Lutomirski <luto@amacapital.net> wrote: > On Thu, Sep 17, 2015 at 12:19 AM, Ingo Molnar <mingo@kernel.org> wrote: > > > > * Andy Lutomirski <luto@kernel.org> wrote: > > > >> Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently > >> turns all rdmsr and wrmsr operations into the safe variants without > >> any checks that the operations actually succeed. > >> > >> This is IMO awful: it papers over bugs. In particular, KVM gueests > >> might be unwittingly depending on this behavior because > >> CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not > >> aware of any such problems, but applying this series would be a good > >> way to shake them out. > >> > >> Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n > >> and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen > >> maintainers are welcome to make a similar change on top of this. > >> > >> Since there's plenty of time before the next merge window, I think > >> we should apply and fix anything that breaks. > > > > No, I think we should at most generate a warning instead, and not crash the kernel > > via rdmsr()! > > > > Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I checked Ubuntu and > > Fedora), so we are potentially exposing a lot of users to problems. > > > > Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are > > non-critical and returning the 'safe' result is much better than crashing or > > hanging the bootup. > > > > Should we do that for CONFIG_PARAVIRT=n, too? Absolutely. PARAVIRT=n should not behave differently from PARAVIRT=y on bare metal. > It would be straightforward to rig this up (temporarily?) on top of these > patches. To keep bloat down, we might want to implement it in > do_general_protection rather than sticking it in native_read_msr. Fair enough. > wrmsr is a different beast, since we can fail due to writing the wrong value to > an otherwise valid MSR. Given that MSR screwups can very easily be security > holes, I'm not sure that warning and blindly continuing on an unchecked failed > wrmsr is a good idea. So the fact is that right now we are silently ignoring failures there, and have been doing that for some time. The right first step is to live with that and start generating low-key, once-per-bootup warnings at most, and see how frequent (and how serious) they are. We could add a (default disabled) CONFIG_PANIC_ON_UNKNOWN_MSR=y option if that's really a serious concern. > In any event, I think it's nuts that CONFIG_PARAVIRT changes this > behavior. We should pick something sane and stick with it. Absolutely - and as it happens, the 'does not crash the kernel' PARAVIRT=y accidental behavior is actually quite close to what we wanted for a long time, so let's make it official - and add a warning to make sure we are aware of problems. But don't turn 'potential problems' into showstopper bugs such as a hard to debug early boot crash, which to most Linux users means a black screen on bootup! > > ( We should double check that rdmsr()/wrmsr() results are never left > > uninitialized, but are set to zero or so, for cases where the return code is not > > checked. ) > > It sure looks like native_read_msr_safe doesn't clear the output if the rdmsr > fails. Yeah, that should be fixed, to make such soft failures deterministic. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2015-09-17 21:00 +0200 |
| Message-ID | <q9Mzv-3V4-3@gated-at.bofh.it> |
| In reply to | #1227250 |
On Thu, Sep 17, 2015 at 10:30 AM, Ingo Molnar <mingo@kernel.org> wrote: > > * Andy Lutomirski <luto@amacapital.net> wrote: > >> On Thu, Sep 17, 2015 at 12:19 AM, Ingo Molnar <mingo@kernel.org> wrote: >> > >> > * Andy Lutomirski <luto@kernel.org> wrote: >> > >> >> Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently >> >> turns all rdmsr and wrmsr operations into the safe variants without >> >> any checks that the operations actually succeed. >> >> >> >> This is IMO awful: it papers over bugs. In particular, KVM gueests >> >> might be unwittingly depending on this behavior because >> >> CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not >> >> aware of any such problems, but applying this series would be a good >> >> way to shake them out. >> >> >> >> Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n >> >> and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen >> >> maintainers are welcome to make a similar change on top of this. >> >> >> >> Since there's plenty of time before the next merge window, I think >> >> we should apply and fix anything that breaks. >> > >> > No, I think we should at most generate a warning instead, and not crash the kernel >> > via rdmsr()! >> > >> > Most big distro kernels on bare metal have CONFIG_PARAVIRT=y (I checked Ubuntu and >> > Fedora), so we are potentially exposing a lot of users to problems. >> > >> > Crashing the bootup on an unknown MSR is bad. Many MSR reads and writes are >> > non-critical and returning the 'safe' result is much better than crashing or >> > hanging the bootup. >> > >> >> Should we do that for CONFIG_PARAVIRT=n, too? > > Absolutely. PARAVIRT=n should not behave differently from PARAVIRT=y on bare > metal. > >> It would be straightforward to rig this up (temporarily?) on top of these >> patches. To keep bloat down, we might want to implement it in >> do_general_protection rather than sticking it in native_read_msr. > > Fair enough. > >> wrmsr is a different beast, since we can fail due to writing the wrong value to >> an otherwise valid MSR. Given that MSR screwups can very easily be security >> holes, I'm not sure that warning and blindly continuing on an unchecked failed >> wrmsr is a good idea. > > So the fact is that right now we are silently ignoring failures there, and have > been doing that for some time. The right first step is to live with that and start > generating low-key, once-per-bootup warnings at most, and see how frequent (and > how serious) they are. > > We could add a (default disabled) CONFIG_PANIC_ON_UNKNOWN_MSR=y option if that's > really a serious concern. Could we abuse panic_on_oops for this purpose? > >> In any event, I think it's nuts that CONFIG_PARAVIRT changes this >> behavior. We should pick something sane and stick with it. > > Absolutely - and as it happens, the 'does not crash the kernel' PARAVIRT=y > accidental behavior is actually quite close to what we wanted for a long time, so > let's make it official - and add a warning to make sure we are aware of problems. > > But don't turn 'potential problems' into showstopper bugs such as a hard to debug > early boot crash, which to most Linux users means a black screen on bootup! > Fair enough. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-09-17 11:10 +0200 |
| Message-ID | <q9Dmx-7n1-11@gated-at.bofh.it> |
| In reply to | #1226577 |
On Wed, Sep 16, 2015 at 04:33:11PM -0700, Andy Lutomirski wrote: > Setting CONFIG_PARAVIRT=y has an unintended side effect: it silently > turns all rdmsr and wrmsr operations into the safe variants without > any checks that the operations actually succeed. > > This is IMO awful: it papers over bugs. In particular, KVM gueests > might be unwittingly depending on this behavior because > CONFIG_KVM_GUEST currently depends on CONFIG_PARAVIRT. I'm not > aware of any such problems, but applying this series would be a good > way to shake them out. > > Fix it so that the MSR operations work the same on CONFIG_PARAVIRT=n > and CONFIG_PARAVIRT=y as long as Xen isn't being used. The Xen > maintainers are welcome to make a similar change on top of this. > > Since there's plenty of time before the next merge window, I think > we should apply and fix anything that breaks. > > Doing this is probably a prerequisite to sanely decoupling > CONFIG_KVM_GUEST and CONFIG_PARAVIRT, which would probably make > Arjan and the rest of the Clear Containers people happy :) So I actually like this, although by Ingo's argument, its a tad risky. But the far greater problem I have with the whole virt thing is that you cannot use rdmsr_safe() to probe if an MSR exists at all because, as you told me, these virt thingies return 0 for all 'unknown' MSRs instead of faulting. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Paolo Bonzini <pbonzini@redhat.com> |
|---|---|
| Date | 2015-09-17 13:50 +0200 |
| Message-ID | <q9FRp-2rZ-29@gated-at.bofh.it> |
| In reply to | #1226784 |
On 17/09/2015 10:58, Peter Zijlstra wrote: > But the far greater problem I have with the whole virt thing is that > you cannot use rdmsr_safe() to probe if an MSR exists at all because, as > you told me, these virt thingies return 0 for all 'unknown' MSRs instead > of faulting. At least for KVM, that behavior is opt-in (the ignore_msrs parameter) and no distro that I know enables it by default. Paolo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-09-17 14:40 +0200 |
| Message-ID | <q9GDN-3D9-41@gated-at.bofh.it> |
| In reply to | #1226938 |
On Thu, Sep 17, 2015 at 01:40:30PM +0200, Paolo Bonzini wrote: > > > On 17/09/2015 10:58, Peter Zijlstra wrote: > > But the far greater problem I have with the whole virt thing is that > > you cannot use rdmsr_safe() to probe if an MSR exists at all because, as > > you told me, these virt thingies return 0 for all 'unknown' MSRs instead > > of faulting. > > At least for KVM, that behavior is opt-in (the ignore_msrs parameter) > and no distro that I know enables it by default. Ah, that would be good news. Andy earlier argued I could not rely on rdmsr_safe() faulting on unknown MSRs. If practically we can there's some code I can simplify :-) -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Date | 2015-09-17 17:20 +0200 |
| Message-ID | <q9J8C-7rl-25@gated-at.bofh.it> |
| In reply to | #1226966 |
On Sep 17, 2015 5:33 AM, "Peter Zijlstra" <peterz@infradead.org> wrote: > > On Thu, Sep 17, 2015 at 01:40:30PM +0200, Paolo Bonzini wrote: > > > > > > On 17/09/2015 10:58, Peter Zijlstra wrote: > > > But the far greater problem I have with the whole virt thing is that > > > you cannot use rdmsr_safe() to probe if an MSR exists at all because, as > > > you told me, these virt thingies return 0 for all 'unknown' MSRs instead > > > of faulting. > > > > At least for KVM, that behavior is opt-in (the ignore_msrs parameter) > > and no distro that I know enables it by default. > > Ah, that would be good news. Andy earlier argued I could not rely on > rdmsr_safe() faulting on unknown MSRs. If practically we can there's > some code I can simplify :-) I was taking about QEMU TCG, not KVM. --Andy -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web