Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp907220ybg; Wed, 3 Jun 2020 17:32:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3u7t/7bW/wdUpGv+ndGFVCRoXPbGwPZCGEYE8oaq2erjivX4KlBf0Smrm54MQlgcg8PlT X-Received: by 2002:a17:906:938b:: with SMTP id l11mr1633522ejx.99.1591230724224; Wed, 03 Jun 2020 17:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591230724; cv=none; d=google.com; s=arc-20160816; b=IOPdEmdFek8HQUnxH7ieIQ9pApdDXm1K76bzIMRlHhYce/XcvtLbEjNVb3a/mrx+19 4t24ziYqJew0PosniVmpjJxwynZG4dr0ReR3h4bsvv9xDq2kf/OEOKiAVEWG/00waFGu hQEdsmJOIWz3fiZfCAWrIy1bY6izIvzcHgYXS08GbtN+0Xgfn0PxRcYlZJyP8AFGhzXE Z/xaCHkVtLWSL8CTsjBJRteqm7PpNDDjl5YmAZnfyn7n4i9fCDdFI5GI1Hp+CksADCK7 NktLM2vJpdk/n1TLxlMc+IX3TR6aQZsEajv3bzFp/ndsBfIbN4LKLPcXKpt+KwIeb7zk vuow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=PLO8a3bdpg4YlUOsfeh2lmi6/2kJrV+rcUr6XYy4E58=; b=TKzXN6IvK8Trs7C+/oJPi3mf1juG+rq3KhBVAIe29SIekQOaK6eHw8tDH+e3Ask8uW SkPQy9q2ueEuzPgXMNGWrPJHUBD4jyyqP2GbSBjyTekPQd80MbxASeUeT9hy2kfu4Ff4 pbUzitvc+8ohJgs4RFXmzxrPUkDrEHUXydMbJybHqAG6XE/iRIdqClRiBm7dLftXfZT8 f2F+tdnHVHKUXpeucPP8fWqHK5ncBoeNY+R3nFzuETsUPPZ8MWKd+L7YEXtUeTh4LY6G Louy0VxB2uJ4WhpbCKklKRAPW1+CiCW5nH+9Ubqxr1hcDFf3FRy374j0hFAp0hwOlz/Z 9p0w== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du12si778088ejc.398.2020.06.03.17.31.41; Wed, 03 Jun 2020 17:32:04 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726109AbgFDAM0 (ORCPT + 99 others); Wed, 3 Jun 2020 20:12:26 -0400 Received: from mga01.intel.com ([192.55.52.88]:17980 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725946AbgFDAM0 (ORCPT ); Wed, 3 Jun 2020 20:12:26 -0400 IronPort-SDR: rykNK4llDOAaIrdT6GL/fjo2+08FyTLOCIHr+5QJxgCMur5SpdIv4wYnPnQcWued3wwX5uWszL gGZitSrnVLPQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jun 2020 17:12:25 -0700 IronPort-SDR: vLKpQoiUNSz8CAkq+y/Z+ba6UdkKLP7XcEPAKUm++OYCjS/AT36sZnoj+kmjxIg29FJeaUauXC HKeH8BDefzHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,470,1583222400"; d="scan'208";a="269244460" Received: from ranerica-svr.sc.intel.com ([172.25.110.23]) by orsmga003.jf.intel.com with ESMTP; 03 Jun 2020 17:12:24 -0700 Date: Wed, 3 Jun 2020 17:12:43 -0700 From: Ricardo Neri To: Brendan Shanks Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, x86@kernel.org, ebiederm@xmission.com, andi@notmuch.email, Babu.Moger@amd.com Subject: Re: [PATCH] x86/umip: Add emulation/spoofing for SLDT and STR instructions Message-ID: <20200604001243.GA24742@ranerica-svr.sc.intel.com> References: <20200602184212.10813-1-bshanks@codeweavers.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200602184212.10813-1-bshanks@codeweavers.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 02, 2020 at 11:42:12AM -0700, Brendan Shanks wrote: > Add emulation/spoofing of SLDT and STR for both 32- and 64-bit > processes. > > Wine users have found a small number of Windows apps using SLDT that > were crashing when run on UMIP-enabled systems. > > Reported-by: Andreas Rammhold > Originally-by: Ricardo Neri > Signed-off-by: Brendan Shanks > --- > arch/x86/kernel/umip.c | 23 ++++++++++++++--------- > 1 file changed, 14 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kernel/umip.c b/arch/x86/kernel/umip.c > index 8d5cbe1bbb3b..59dfceac5cc0 100644 > --- a/arch/x86/kernel/umip.c > +++ b/arch/x86/kernel/umip.c > @@ -64,6 +64,8 @@ > #define UMIP_DUMMY_GDT_BASE 0xfffffffffffe0000ULL > #define UMIP_DUMMY_IDT_BASE 0xffffffffffff0000ULL > > +#define UMIP_DUMMY_TASK_REGISTER_SELECTOR 0x40 > + > /* > * The SGDT and SIDT instructions store the contents of the global descriptor > * table and interrupt table registers, respectively. The destination is a > @@ -244,16 +246,24 @@ static int emulate_umip_insn(struct insn *insn, int umip_inst, > *data_size += UMIP_GDT_IDT_LIMIT_SIZE; > memcpy(data, &dummy_limit, UMIP_GDT_IDT_LIMIT_SIZE); > > - } else if (umip_inst == UMIP_INST_SMSW) { > - unsigned long dummy_value = CR0_STATE; > + } else if (umip_inst == UMIP_INST_SMSW || umip_inst == UMIP_INST_SLDT || > + umip_inst == UMIP_INST_STR) { > + unsigned long dummy_value; > + > + if (umip_inst == UMIP_INST_SMSW) > + dummy_value = CR0_STATE; > + else if (umip_inst == UMIP_INST_STR) > + dummy_value = UMIP_DUMMY_TASK_REGISTER_SELECTOR; > + else > + dummy_value = 0; Perhaps you can return a non-zero value for SLDT if it has an LDT, as Andy had suggested. Maybe this can be implemented by looking at current->mm->context.ldt I guess the non-zero value can be (GDT_ENTRY_LDT*8). Thanks and BR, Ricardo