Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp3748959ybk; Tue, 19 May 2020 12:01:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr9/5I2zyGHwsWVjztWAqTSRwL6XYu3lzWypRZd68Zo/pFL7K0/PH9eRS77mgRJMNTnIWz X-Received: by 2002:a17:907:9492:: with SMTP id dm18mr643276ejc.328.1589914893116; Tue, 19 May 2020 12:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589914893; cv=none; d=google.com; s=arc-20160816; b=rgJ7FmTC0u6SN4K0x5o4SsbOCRCTQF2Tmf0KUGvvsdxTaG8fc6FxyL1wkmKfEdJUVX WXLynfFrYN9DnxGL/Eak0vY/RHfr/RaDDPm73dkuFsyZQ8y5dvQIzYs84AiMKG3eNXsL /rYfF6dHZX84EC1x8LMsGJZJPoyXZ9LRz1gizh/BX0RjfUJdJww3G/X1SWbGVPm6gQoO t1bFymDvO/PWzQnh7hYNFVrKSpYDPDiDO5oGBG7V9XCM8WW7SNqo+9nBUffCf7e4S74w ZVQ5GIb7952x5U616X3cuZWkS7tTCA63B/Vg5Nf6i0UVQ+Pl9P0j6u+y+UWfLQA8dLj+ PzPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=4sA6AxHh/ziYHSgQrSVViGoQNOC/5kTIcBK+ywm7WM8=; b=cDzjMITl+qBYd1PS6+rd+1EOYIYpsDiw/+9HdOPKqSVhEsMmTkOEF2ISy9O9FHwC3O +mwF5e4b92PCJ0Adx6WJGRqJub1ILXvVUjKY4AwdNUSMqWrEK9bMhmxkM91BFyA2GLNn /rrwTNHCJpEVAM2S/h334JoSuAXLizWNyKksXIXtuR3Ve7FQL0Sy/NY/b0YPAlFZPn3B aNWfFFZBVk34Q9RU8W7YyPISvai8Mx340ZPY0h+W5yx2FSACXtb4anHafNsh9RkWPWxL gprb8TRTHyxV0LVwcHs/hmteeGfQMeIWc2ZjJyE7mCnuln8QfvhBZPbQOmCyn/wwnPRy AILw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@codeweavers.com header.s=6377696661 header.b=b0fhpks8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nj4si366731ejb.643.2020.05.19.12.01.08; Tue, 19 May 2020 12:01:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@codeweavers.com header.s=6377696661 header.b=b0fhpks8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codeweavers.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726725AbgESS4w (ORCPT + 99 others); Tue, 19 May 2020 14:56:52 -0400 Received: from mail.codeweavers.com ([50.203.203.244]:43440 "EHLO mail.codeweavers.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726623AbgESS4v (ORCPT ); Tue, 19 May 2020 14:56:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=codeweavers.com; s=6377696661; h=To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=4sA6AxHh/ziYHSgQrSVViGoQNOC/5kTIcBK+ywm7WM8=; b=b0fhpks8c2xrL3LgleivySapX xvZB69j32yfrQ77ghvImYfV90a7n9tsyLPhtCRxsw+wkepPVmNTFHIdDzcuD8ax98f2jFBAcYDGPg 1AWW45r0sKxIyEmQ7kOM9RtsKbgrhUsQR7wrTlPzCQrQLEdJWgkyTiP5dQ290FM9wvDzQ=; Received: from cpe-107-184-2-226.socal.res.rr.com ([107.184.2.226] helo=[192.168.2.117]) by mail.codeweavers.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1jb7Pu-0007Ru-Pf; Tue, 19 May 2020 13:56:45 -0500 Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Subject: Re: umip: AMD Ryzen 3900X, pagefault after emulate SLDT/SIDT instruction From: Brendan Shanks In-Reply-To: <20200519143815.cpsd2xfx2kl3khsq@wrt> Date: Tue, 19 May 2020 11:56:40 -0700 Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Ricardo Neri , "Eric W. Biederman" , Sergey Senozhatsky , Babu Moger , Kefeng Wang , Jason Yan , linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <2330FAB4-A6CE-49E7-921C-B7D55763BDED@codeweavers.com> References: <20200519143815.cpsd2xfx2kl3khsq@wrt> To: Andreas Rammhold X-Mailer: Apple Mail (2.3445.104.14) X-Spam-Score: -25.7 X-Spam-Report: Spam detection software, running on the system "mail.codeweavers.com", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: > On May 19, 2020, at 7:38 AM, Andreas Rammhold wrote: > > Hi, > > I've been running into a weird problem with UMIP on a current Ryzen > 3900x with kernel 5.6.11 where a process r [...] Content analysis details: (-25.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -20 USER_IN_WHITELIST From: address is in the user's white-list -6.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -0.5 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.8 AWL AWL: Adjusted score from AWL reputation of From: address Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 19, 2020, at 7:38 AM, Andreas Rammhold = wrote: >=20 > Hi, >=20 > I've been running into a weird problem with UMIP on a current Ryzen > 3900x with kernel 5.6.11 where a process receives a page fault after = the > kernel handled the SLDT (or SIDT) instruction (emulation). >=20 > The program I am running is run through WINE in 32bit mode and tries = to > figure out if it is running in a VMWare machine by comparing the = results > of SLDT against well known constants (basically as shown in the > [example] linked below). >=20 > In dmesg I see the following log lines: >> [99970.004756] umip: Program.exe[3080] ip:4373fb sp:32f3e0: SIDT = instruction cannot be used by applications. >> [99970.004757] umip: Program.exe[3080] ip:4373fb sp:32f3e0: For now, = expensive software emulation returns the result. >> [99970.004758] umip: Program.exe[3080] ip:437415 sp:32f3e0: SLDT = instruction cannot be used by applications. >=20 > Following that the process terminates with a page fault: >> Unhandled exception: page fault on read access to 0xffffffff in = 32-bit code (0x0000000000437415). >=20 > Assembly at that address: >> 0x0000000000437415: sldt 0xffffffe8(%ebp) >=20 > Running the same executable on the exact same kernel (and userland) = but > on a Intel i7-8565U doesn't crash at this point. I am guessing the > emulation is supposed to do something different on AMD CPUs? >=20 > On the Ryzen the code executes successfully after setting = CONFIG_X86_UMIP=3Dn. Hi Andreas, The problem is that the kernel does not emulate/spoof the SLDT = instruction, only SGDT, SIDT, and SMSW. SLDT and STR weren't thought to be commonly used, so emulation/spoofing = wasn=E2=80=99t added. In the last few months I have seen reports of one or two (32-bit) = Windows games that use SLDT though. Can you share more information about the application you=E2=80=99re = running? Maybe the best path is to add kernel emulation/spoofing for SLDT and STR = on 32 and 64-bit, just to cover all the cases. It should be a pretty = simple patch, I=E2=80=99ll start working on it. Alternately, I did work on a Wine patch to emulate the UMIP instructions = in user-space, but it adds a lot of code and I don=E2=80=99t think = there=E2=80=99s much appetite for it in upstream Wine (especially since = the kernel emulation is sufficient for almost all cases). https://www.winehq.org/pipermail/wine-devel/2020-February/160027.html In the meantime, an easy way to disable UMIP without rebuilding the = kernel is to pass 'clearcpuid=3D514=E2=80=99 on the kernel command line. Brendan Shanks CodeWeavers