From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751415AbdE3My0 (ORCPT ); Tue, 30 May 2017 08:54:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51232 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750898AbdE3MyY (ORCPT ); Tue, 30 May 2017 08:54:24 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 59AB93D967 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=rkrcmar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 59AB93D967 Date: Tue, 30 May 2017 14:54:21 +0200 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Gioh Kim Cc: andre.przywara@amd.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] KVM: SVM: ignore type when setting segment registers Message-ID: <20170530125420.GA19724@potion> References: <1496064244-14785-1-git-send-email-gi-oh.kim@profitbricks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1496064244-14785-1-git-send-email-gi-oh.kim@profitbricks.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 30 May 2017 12:54:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-05-29 15:24+0200, Gioh Kim: > Current code sets unusable as 1 if present is 1 and type is 0. > In Long mode, type value in segment descriptor is ignored. > So I think type should be ignored when setting the segment registers, > if type means the descriptor type in the segment descriptor. > > Is the type field of struct kvm_segment the descriptor type? Yes. > If so, why type is checked when setting segment registers? No idea. 19bca6ab75d8 ("KVM: SVM: Fix cross vendor migration issue with unusable bit") also moved the assigment up to initialize it before use and I think that is enough. > If the type field is not the descriptor type, > is it ok to set unusable when present is 1? Looks like a bug. type = 0 can be a usable read-only data segment. > I'm copying a code as following to show what code I'm asking. Please send it as a patch, thanks. > ----------------------------- 8< --------------------------------- > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 5f48f62..0133f6f 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -1803,7 +1803,7 @@ static void svm_get_segment(struct kvm_vcpu *vcpu, > * AMD's VMCB does not have an explicit unusable field, so emulate it > * for cross vendor migration purposes by "not present" > */ > - var->unusable = !var->present || (var->type == 0); > + var->unusable = !var->present; > > switch (seg) { > case VCPU_SREG_TR: > -- > 2.5.0 >