Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751273AbeAPO4m (ORCPT + 1 other); Tue, 16 Jan 2018 09:56:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59430 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750790AbeAPO4k (ORCPT ); Tue, 16 Jan 2018 09:56:40 -0500 Subject: Re: [RFC 0/6] Enlightened VMCS support for KVM on Hyper-V To: Vitaly Kuznetsov , Paolo Bonzini Cc: Wanpeng Li , kvm , the arch/x86 maintainers , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , "Michael Kelley (EOSG)" , Mohammed Gamal , Cathy Avery , Bandan Das , linux-kernel@vger.kernel.org References: <20180115173105.31845-1-vkuznets@redhat.com> <87inc2huux.fsf@vitty.brq.redhat.com> <87tvvlhplx.fsf@vitty.brq.redhat.com> <87po69hnir.fsf@vitty.brq.redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <0880f34c-38d7-8612-b57a-085cb44cf3cc@redhat.com> Date: Tue, 16 Jan 2018 15:56:11 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <87po69hnir.fsf@vitty.brq.redhat.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.38]); Tue, 16 Jan 2018 14:56:40 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 16.01.2018 15:43, Vitaly Kuznetsov wrote: > Paolo Bonzini writes: > >> On 16/01/2018 14:58, Vitaly Kuznetsov wrote: >>>> Haven't looked into the details, but we have to watch out for other >>>> VCPUs trying to modify that vmcs12. >>>> >>>> Basically because other VCPUs could try to modify values in vmcs12 while >>>> we are currently building vmcs02. Nasty races could result in us copying >>>> stuff (probably unchecked) into vmcs02 and therefore running something >>>> that was not intended. >>>> >>> I don't think we share VMCS among vCPUs, do we? >> >> VMCS is just memory, so who knows what a malicious L1 guest will do. >> But for vmread/vmwrite we can go through hypervisor memory, for >> enlightened VMCS we cannot. >> > > True; not sure if Hyper-V actually copies the data to some internal > storage, probably it does. TLFS explicitly forbids making the same > enlightened VMCS active on several vCPUs simultaneously but again, this > is just memory... > FWIF, on nested s390x we pin the guest provided SIE control block ("SCB" - s390x VMCS12). As this is just guest memory, another VCPU can write to that memory. When building our shadow SCB ("VMCS02"), we directly access the pinned block, but we basically only copy values and mask them for the critical parts (execution controls). However, as I realize, the compiler might fetch values several times, so we better add READ_ONCE() to these places. Will look into that. -- Thanks, David / dhildenb