Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751574AbdFAJWG (ORCPT ); Thu, 1 Jun 2017 05:22:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57198 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751135AbdFAJWE (ORCPT ); Thu, 1 Jun 2017 05:22:04 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 28075624B0 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=pbonzini@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 28075624B0 Subject: Re: [PATCH 1/1] KVM: SVM: do not zero out segment attributes if segment is unusable or not present To: Roman Pen Cc: Mikhail Sennikovskii , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170601085503.12852-1-roman.penyaev@profitbricks.com> From: Paolo Bonzini Message-ID: <16c1d0ed-2c05-d5e1-4540-b862aed660ab@redhat.com> Date: Thu, 1 Jun 2017 11:22:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170601085503.12852-1-roman.penyaev@profitbricks.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 01 Jun 2017 09:22:04 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1474 Lines: 35 On 01/06/2017 10:55, Roman Pen wrote: > This is a fix for the problem [1], where VMCB.CPL was set to 0 and interrupt > was taken on userspace stack. The root cause lies in the specific AMD CPU > behaviour which manifests itself as unusable segment attributes on SYSRET. > The corresponding work around for the kernel is the following: > > 61f01dd941ba ("x86_64, asm: Work around AMD SYSRET SS descriptor attribute issue") > > In other turn virtualization side treated unusable segment incorrectly and > restored CPL from SS attributes, which were zeroed out few lines above. > > In current patch it is assured only that P bit is cleared in VMCB.save state > and segment attributes are not zeroed out if segment is not presented or is > unusable, therefore CPL can be safely restored from DPL field. > > This is only one part of the fix, since QEMU side should be fixed accordingly > not to zero out attributes on its side. Corresponding patch will follow. > > [1] Message id: CAJrWOzD6Xq==b-zYCDdFLgSRMPM-NkNuTSDFEtX=7MreT45i7Q@mail.gmail.com > > Signed-off-by: Roman Pen > Signed-off-by: Mikhail Sennikovskii > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: kvm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/x86/kvm/svm.c | 24 +++++++++++------------- > 1 file changed, 11 insertions(+), 13 deletions(-) Queued, thanks! Paolo