Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2914779ybt; Mon, 22 Jun 2020 10:05:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNvYnbk6h45PeBcx655ycn+dgjBL4eZrLL0L3Gc/OT+/AajXu30+4Hr/BvgXmBMF8fxzzH X-Received: by 2002:a17:906:e05:: with SMTP id l5mr17741520eji.318.1592845559050; Mon, 22 Jun 2020 10:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592845559; cv=none; d=google.com; s=arc-20160816; b=NAL2ANLR/W/601R+RA8XA8wz44QpgjmJhhLoE6tZUm4a+LDq/viECmF6yKJVbNxqnr dYuihbtC3kbGMJYKDNnW7hR1q1toj7B5csPiI/v38czvh1bI60A4EhMhGIEfmAvTpimQ 2fAKBLUffzunGCr5hqBHgrFagYgdx7LrQWxHENgPTZtWq+QMMJSv0xNTpRFnZf+xZ/dE FV4S7MLe5xqUrig3tKcfzo9t4EsaegFGv9i64Xu3iYATBb2fPjdM76ZeFXIpz+yZpXky yEpdG/nZhAo0wP7zwttEU4h4oh2kNLClGLALPLs8SHkhyeEXBdrU9aOouJf+su5azCBw fnOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=c20PFCYQDvm9Eid24U2nkRH13DnKGthrv5RalXWjuFY=; b=jCZyNhfy1IcKGzSGQ9Q6PyHQT/+Shh7DxKzYWDIqPdJabXD/Cfy1CS3VcPloKfeLBV JNqANOVfSqfHdmQ78iOQrZvx75j7orUco0ThwTf+/ImZOk6VRqRBlgmVGe+1hVYblic+ E2nyg3RTRnXkckm8qlp/yHmVfu2eI4DFhL+goIOqD/f3VWxIs6aaLvzSA626BQydB3yB mz9RAwxo945Squov7N7pLsMzLkBG8mQ2ub6nifudlIrnjzJwCkC6mnMTAdBuUD4AfkqA bfSTeuU5U9CKA8AF6iOHw+L3zB5tVkZ45eeW2REoquLWrmIoD3TZVZ/rKATabwkxd4/d /QxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="g1TJWk/B"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j8si10223811edp.99.2020.06.22.10.05.36; Mon, 22 Jun 2020 10:05:59 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="g1TJWk/B"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729811AbgFVRDd (ORCPT + 99 others); Mon, 22 Jun 2020 13:03:33 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25312 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729492AbgFVRDc (ORCPT ); Mon, 22 Jun 2020 13:03:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592845411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c20PFCYQDvm9Eid24U2nkRH13DnKGthrv5RalXWjuFY=; b=g1TJWk/BljmMMew+ljRgKvBcZu+XkyxdSpCs77J7IhpFdq9mSDR54l5avYepQW9KyxVsyg Bid/i8NHoIFUmn1WpvUtin+OkMZaKRKQEov0dQxpvueEmyGm0kKUcAaOyiHo/vU1FNVE6+ wucMNJLOVSskJZ7UEKhOiE9oOisTyUE= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-d_pv1W_uPhKEyPxTXJvk6A-1; Mon, 22 Jun 2020 13:03:29 -0400 X-MC-Unique: d_pv1W_uPhKEyPxTXJvk6A-1 Received: by mail-wr1-f71.google.com with SMTP id m14so11162893wrj.12 for ; Mon, 22 Jun 2020 10:03:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=c20PFCYQDvm9Eid24U2nkRH13DnKGthrv5RalXWjuFY=; b=b5+O7vkdhm7Mu5kPm+zgdNEjyaR7+j/Ujks9WgQt8Zzj25A/RpMWjBwUZ++gHLWqYg qNMZz1pi7DoNHw7dYFxiymzs3bpqnDypU+nrntle8d9+hETDz7LkVFNPGVfPJZF5CvSr HTUz0DlnZ2EEs4e735fiDxFZWRFoZ2SQakjlxp92GMs6MVy62dGpWDSaN0x+be2wtnFr SYSeqDEN+qeRqcJFqPk39MvccDwr5Uv4dv1LUfgsFDXv/7IT0Sep+OQboPW3HLq0r1qN nqpceixK7LtIPGrXqgHN6pZt9yQtWYO+2V5iploNnrLi8Xu5PKmSYP8M2e8l5iAYxejq 61lw== X-Gm-Message-State: AOAM533SvJ66ODRojgpIfropFEZ00dVTRvImWt3D+bIzOJb0SkVoEDJZ jm7BE7My6FHDeGrau0gm1GiBkwP5CEhl9SZ97MQ9Xyy+MF66dNuKmPe+vSbGuOobE07yKRKnWEx 3SVCWTCZRccfQkOfWZyMNlONr X-Received: by 2002:a1c:2d4b:: with SMTP id t72mr19131616wmt.105.1592845408428; Mon, 22 Jun 2020 10:03:28 -0700 (PDT) X-Received: by 2002:a1c:2d4b:: with SMTP id t72mr19131589wmt.105.1592845408155; Mon, 22 Jun 2020 10:03:28 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:fd64:dd90:5ad5:d2e1? ([2001:b07:6468:f312:fd64:dd90:5ad5:d2e1]) by smtp.gmail.com with ESMTPSA id y25sm197930wma.19.2020.06.22.10.03.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Jun 2020 10:03:27 -0700 (PDT) Subject: Re: [PATCH v2 00/11] KVM: Support guest MAXPHYADDR < host MAXPHYADDR To: Tom Lendacky , Mohammed Gamal , kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, vkuznets@redhat.com, sean.j.christopherson@intel.com, wanpengli@tencent.com, jmattson@google.com, joro@8bytes.org, babu.moger@amd.com References: <20200619153925.79106-1-mgamal@redhat.com> <5a52fd65-e1b2-ca87-e923-1d5ac167cfb9@amd.com> <52295811-f78a-46c5-ff9e-23709ba95a3d@redhat.com> <0d1acded-93a4-c1fa-b8f8-cfca9e082cd1@amd.com> From: Paolo Bonzini Message-ID: <40ac43a1-468f-24d5-fdbf-d012bdae49ed@redhat.com> Date: Mon, 22 Jun 2020 19:03:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <0d1acded-93a4-c1fa-b8f8-cfca9e082cd1@amd.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 22/06/20 18:33, Tom Lendacky wrote: > I'm not a big fan of trapping #PF for this. Can't this have a performance > impact on the guest? If I'm not mistaken, Qemu will default to TCG > physical address size (40-bits), unless told otherwise, causing #PF to now > be trapped. Maybe libvirt defaults to matching host/guest CPU MAXPHYADDR? Yes, this is true. We should change it similar to how we handle TSC frequency (and having support for guest MAXPHYADDR < host MAXPHYADDR is a prerequisite). > In bare-metal, there's no guarantee a CPU will report all the faults in a > single PF error code. And because of race conditions, software can never > rely on that behavior. Whenever the OS thinks it has cured an error, it > must always be able to handle another #PF for the same access when it > retries because another processor could have modified the PTE in the > meantime. I agree, but I don't understand the relation to this patch. Can you explain? > What's the purpose of reporting RSVD in the error code in the > guest in regards to live migration? > >> - if the page is accessible to the guest according to the permissions in >> the page table, it will cause a #NPF. Again, we need to trap it, check >> the guest physical address and inject a P|RSVD #PF if the guest physical >> address has any guest-reserved bits. >> >> The AMD specific issue happens in the second case. By the time the NPF >> vmexit occurs, the accessed and/or dirty bits have been set and this >> should not have happened before the RSVD page fault that we want to >> inject. On Intel processors, instead, EPT violations trigger before >> accessed and dirty bits are set. I cannot find an explicit mention of >> the intended behavior in either the >> Intel SDM or the AMD APM. > > Section 15.25.6 of the AMD APM volume 2 talks about page faults (nested vs > guest) and fault ordering. It does talk about setting guest A/D bits > during the walk, before an #NPF is taken. I don't see any way around that > given a virtual MAXPHYADDR in the guest being less than the host MAXPHYADDR. Right you are... Then this behavior cannot be implemented on AMD. Paolo