Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1476278imm; Thu, 12 Jul 2018 02:32:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcu0ZB1O9uhXMihr8IHn7hUBMZuCjXrrKdNSPcwODgP/NVTrd/hyhRXUDbqlMmQxtJsdgGv X-Received: by 2002:a63:8dca:: with SMTP id z193-v6mr1426149pgd.228.1531387956029; Thu, 12 Jul 2018 02:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531387956; cv=none; d=google.com; s=arc-20160816; b=afkvblfFz65AD6Io/7yQTV/sfTAYeVNbx4V6jETYx5Na34CI4UNPV+2UNRgzCC+Muk rnARBilnP3WvDXr3UvAHVaSedype2CbcmN6mDfpdedzw4bGTqljnYs3EXeRZ/JtQwEx8 i+vVIBJZL0hjuEmP3EkHOxYJeoItESwrlHBwI9nYhM765zYQGuEsvnKRBxf8OndQLJyp bSM1D6LJj5QzdYqcN+N4pPFLOS6KFkbYN3MopAdliKXM+qfVOeG2CvkY99rg8jZQozew flp0cyyN4l/XcOEFrT/I3qhc8DY9z7Ife19Jrvbrqb5vcfkH7UNOYgqilk92hw3TnUBt iL3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from :arc-authentication-results; bh=CWHH1C17pDZfJxdCL9OcBsDa5Hz0inJiaKQfzBg/Sh8=; b=GuvqFDbz2/ZDWnBxE8Yntu26t/6iC9WA6q+DxXiYlmwcMpETAjGJ5BPVy+H87LmokW 6P+7sKXIWqDjI4jBQlcz9cYQGeNWIdw8rk3frBTQy4tnVvzNXAcz/s2+98MKqhMqN8j+ EFf61mF+JsOMbuBqtkcy+uV32Dwz4Yp/j9TkWFgv40Yyj21Rcu337nrqbS8J4IufFzw5 a8PlwvdGoXhfGPx7TXbb8xj/BzQHA5wuFBrhdmpg7WYAXai7sDR5AC74CwKM7jWivY66 tiNIwMVgXl6h0FhMJWmXxGyCVMbXXbpjQWYqJs4ajJ1IP4oRvgIQc70londWzWq88d5m nTow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193-v6si20212715pgh.407.2018.07.12.02.32.20; Thu, 12 Jul 2018 02:32:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbeGLJk3 (ORCPT + 99 others); Thu, 12 Jul 2018 05:40:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50664 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726040AbeGLJk3 (ORCPT ); Thu, 12 Jul 2018 05:40:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF3C1401EF26; Thu, 12 Jul 2018 09:31:43 +0000 (UTC) Received: from vitty.brq.redhat.com.redhat.com (unknown [10.43.2.155]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82DE7111AF0E; Thu, 12 Jul 2018 09:31:42 +0000 (UTC) From: Vitaly Kuznetsov To: Wanpeng Li Cc: kvm , Paolo Bonzini , Radim Krcmar , "the arch\/x86 maintainers" , Andy Lutomirski , ldv@altlinux.org, yamato@redhat.com, LKML Subject: Re: [PATCH] x86/kvm/vmx: don't read current->thread.{fs,gs}base of legacy tasks References: <20180711173718.8850-1-vkuznets@redhat.com> Date: Thu, 12 Jul 2018 11:31:41 +0200 In-Reply-To: (Wanpeng Li's message of "Thu, 12 Jul 2018 09:39:09 +0800") Message-ID: <877em0ztoi.fsf@vitty.brq.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 12 Jul 2018 09:31:44 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Thu, 12 Jul 2018 09:31:44 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'vkuznets@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wanpeng Li writes: > On Thu, 12 Jul 2018 at 08:07, Vitaly Kuznetsov wrote: >> >> When we switched from doing rdmsr() to reading FS/GS base values from >> current->thread we completely forgot about legacy 32-bit userspaces which >> we still support in KVM (why?). task->thread.{fsbase,gsbase} are only >> synced for 64-bit processes, calling save_fsgs_for_kvm() and using >> its result from current is illegal for legacy processes. >> >> There's no ARCH_SET_FS/GS prctls for legacy applications. Base MSRs are, >> however, not always equal to zero. Intel's manual says (3.4.4 Segment >> Loading Instructions in IA-32e Mode): >> >> "In order to set up compatibility mode for an application, segment-load >> instructions (MOV to Sreg, POP Sreg) work normally in 64-bit mode. An >> entry is read from the system descriptor table (GDT or LDT) and is loaded >> in the hidden portion of the segment register. >> ... >> The hidden descriptor register fields for FS.base and GS.base are >> physically mapped to MSRs in order to load all address bits supported by >> a 64-bit implementation. >> " >> >> The issue was found by strace test suite where 32-bit ioctl_kvm_run test >> started segfaulting. > > Test suite: MSR switch > PASS: VM entry MSR load > PASS: VM exit MSR store > PASS: VM exit MSR load > FAIL: VM entry MSR load: try to load FS_BASE > SUMMARY: 4 tests, 1 unexpected failures > > kvm-unit-tests fails w/ and w/o the patch, maybe it is another issue, > i didn't dig further, you can have a look if you are interested in. :) The patch only changes the behavior for legacy userspaces and I can reproduce the failure on native x86_64, it is something different. I'm, however, interested so stay tuned :-) -- Vitaly