[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Making KMSAN compatible with paravirtualization
- To: Vitaly Kuznetsov <vkuznets@xxxxxxxxxx>, Alexander Potapenko <glider@xxxxxxxxxx>
- From: Andrew Cooper <Andrew.Cooper3@xxxxxxxxxx>
- Date: Fri, 11 Nov 2022 15:34:23 +0000
- Accept-language: en-GB, en-US
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=tAtlsusJi2Uehnp+gIp0x/mg5H8s7s0QemxFHGuOce8=; b=UebEQC39n7jg6/HR5bEEem3mb/xcMrpNR442Vrdytbc4PL5X+SZyqBAMuE4Jf6gf/qP+myx21163GTmRmqQnkwDURfezr07hWYBcuvqqwvnVXAq1L8Dj5ezYh99HfbYUsb/HBSuISdZs4RJEl7lIroGOb/dHeetAKRGSMmamLNlUWhAMbPOvGVtmHnNDWj0xYxew1dI2L8zWF5VY9D0WFI4QOqarqmGc6P18QDugACozmSQYsscwJxrU5LAeyn9ocrqct1EehTyihO2fBeSalpG9Z3k4M9R52/rTzDw0rpoanFqo3R9omot/Hff7RR/xIQ8QiqjGAWkp4luCa1wlNA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gOL3gS31xHqeqiQQztyC+11RSEf4JtkvyWC8A2kyglcJ01JOZAFfRrDH8pmZW+w/ywE7RkGIFfHqt+gFaKTCHOaABk48J5gvbGyqXM3ByZ1tcV8aRW6n1FhnLHJvrBGUmPQdn4u2R5wxxa5O8zJ49KhnvWhUkh74+PxZLNhyO2HP+JgXJKdEmRBFXnMtBtCiINVGIWZNcEaTbjWv7BOFgMermKxOxJypSE5pDeqaEpdoEXCqddTGjUWD67OkLaoGhV+47HKzUvqLeeAWZ8FtFJvctGsZq4Wo3QBTz0xTKcq5Dr5x8fsl1iFxR9lme8W/1gtDQgejGK5iMl6D8Xs0VA==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>, "kvm@xxxxxxxxxxxxxxx" <kvm@xxxxxxxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Paolo Bonzini <pbonzini@xxxxxxxxxx>, Wanpeng Li <wanpengli@xxxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, "srivatsa@xxxxxxxxxxxxx" <srivatsa@xxxxxxxxxxxxx>
- Delivery-date: Fri, 11 Nov 2022 15:34:40 +0000
- Ironport-data: A9a23:dtVhLam0kYEQYpLHpjTpY2Ho5gwrJ0RdPkR7XQ2eYbSJt1+Wr1Gzt xIaWzjQMvyKN2r3co9/OYy+oUoF65PTzdA1HlRuqyE0RiMWpZLJC+rCIxarNUt+DCFhoGFPt JxCN4aafKjYaleG+39B55C49SEUOZmgH+a6U6icf3grHmeIcQ954Tp7gek1n4V0ttawBgKJq LvartbWfVSowFaYCEpNg064gE4p7aqaVA8w5ARkP6kS5QaGzhH5MbpETU2PByqgKmVrNrbSq 9brlNmR4m7f9hExPdKp+p6TnpoiG+O60aCm0xK6aoD66vRwjnVaPpUTbZLwXXx/mTSR9+2d/ f0W3XCGpaXFCYWX8AgVe0Ew/yiTpsSq8pefSZS0mZT7I0Er7xIAahihZa07FdRwxwp5PY1B3 dElMTYwbQmDvM633ryHcuRg3uY+EPC+aevzulk4pd3YJdAPZMiZBonvvppf1jp2gd1SF/HDY cZfcSBocBnLfxxIPBEQFY46m+CrwHL4dlW0qnrM/fZxvzeVkVI3jOCF3Nn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XHMWwvFNCaILU3gD7xvAQOFl3fb2sRD2AiRQu1/8LIi3J DaFF9Iv287fEzjTcWIwZ1Q6xjIBGGwRy7kxM1S74Vw/uSUfsuhDQSTDFQ118ewqfQWBcPWH/ 61JZJNGvfmaW/jA5xA0QHyU4RbbXMeTMoWsNAmXE/mmLOCFqT68ujANPrDLrvkFjgpHmv5H3 sYRTD2YN5N60i6M0WI9CQ5m0mdD3AX0agAY5QypdJjubTlHrc8wjQ9mBC++tyBLyFEv+g/YF Z+SYmX4J+GmQ==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHY9eFcHH1JYMsgREmwx+zG/XY6ba452mKA
- Thread-topic: Making KMSAN compatible with paravirtualization
On 11/11/2022 15:21, Vitaly Kuznetsov wrote:
> Alexander Potapenko <glider@xxxxxxxxxx> writes:
>
>> Hi,
>>
>> While investigating KMSAN's incompatibilities with the default Ubuntu
>> config (https://github.com/google/kmsan/issues/89#issuecomment-1310702949),
>> I figured out that a kernel won't boot with both CONFIG_KMSAN=y and
>> CONFIG_XEN_PV=y.
>>
>> In particular, it may crash in load_percpu_segment():
>>
>> __loadsegment_simple(gs, 0);
>> wrmsrl(MSR_GS_BASE, cpu_kernelmode_gs_base(cpu));
>>
>> Here the value of %gs between __loadsegment_simple() and wrmsrl() is
>> zero, so when KMSAN's __msan_get_context_state() instrumentation
>> function is called before the actual WRMSR instruction is performed,
>> it will attempt to access percpu data and crash.
>>
>> Unless instructed otherwise (by noinstr or __no_sanitize_memory on the
>> source level, or by KMSAN_SANITIZE := n on the Makefile level), KMSAN
>> inserts instrumentation at function prologue for every non-inlined
>> function, including native_write_msr().
>>
>> Marking native_write_msr() noinstr actually makes the kernel boot for
>> me, but I am not sure if this is enough. In fact we'll need to fix
>> every situation in which instrumentation code may be called with
>> invalid %gs value. Do you think this is feasible? Overall, should we
>> care about KMSAN working with paravirtualization?
> I think XEN PV is really special, let's Cc: xen-devel@ first.
Xen PV has some some quirks, but it's really not as special as most
people think. Certainly not relevant here.
It's actually load_percpu_segment() which is broken here, and was fixed
in the call depth tracking series.
https://lore.kernel.org/lkml/166601847113.401.13616810593513367893.tip-bot2@tip-bot2/
~Andrew
|