Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp974328ybl; Fri, 24 Jan 2020 13:01:26 -0800 (PST) X-Google-Smtp-Source: APXvYqxetCZSw1+UzE9CfvfZf8hBVygfA0jL9ai+AmERXSHy+mP71r1NmCuv+UO6pmOQywuTowKt X-Received: by 2002:a05:6830:1294:: with SMTP id z20mr4089604otp.60.1579899686310; Fri, 24 Jan 2020 13:01:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579899686; cv=none; d=google.com; s=arc-20160816; b=najGZYsIpiwe1rnMOb02gEhp0V6FMwDqe+h1eD2xXBk7E0NHRUeSHBGAnvWiU4DzZK rAZaR4IMMxheco//PuqDoF45DpZgcn4r9KyidhhlD1eHZHU6y/7U5A0DEfSF9sTb69Hf O1VOwr97hc6PYu0Z6sqjiCkL0sFnAxXtMeeEbnYSP6EyzLIO5ULLkJcvv0BsGJLb9xHe 4Kpyd2zmLGhS+s3mR1g8MtO0Odgah7h5kX0vhHWlXBZ8atDqEO9lsARKFbRQOYwXV7+6 AFI7woSRi7jFt0UIygbxcbpLerY6F4hgJi4qy5ovHhdMBoOTB0QdW6eswTYpc7g4Jui0 t9qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=k9IbFX230h+2YJkS//36Bone21Vlk4mvmv7ukUtwlrg=; b=HPgyCIGUkmQgxGceK059oWycRtIgQYFZg3bQ8l4Yi+9p78OuGO8K5e3dAKTZVRn/Pe SLW9E9MW/U4xRNYkCTh22H33U/TTsMQoTt7pJ4rfrg8XyScp3cxxlYwd3kJIQDNALY3z ZlJNwt4j9V/Rr+WVRTcA0W3jpg1SC/Qyxyfrui6hntiehhL8GwDeqhxNGRMGPELZsyU9 fhNFmjGvuJ9EQpWBC/6/QrzRrWSpRvsPY/mJFO2WP3LSHGTRx9C/uLhiDipnFcnZMG/n 0cvE4xNU/1GQClDdIF6VLdtppS5wEMCVKpswktbjzAVgJU9qninUCzne6pIBUEcdQjZb 3KYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=DAXjtZMQ; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i12si3475560otl.74.2020.01.24.13.01.13; Fri, 24 Jan 2020 13:01:26 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20161025 header.b=DAXjtZMQ; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389872AbgAXSyK (ORCPT + 99 others); Fri, 24 Jan 2020 13:54:10 -0500 Received: from mail-vk1-f193.google.com ([209.85.221.193]:37240 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391148AbgAXSyK (ORCPT ); Fri, 24 Jan 2020 13:54:10 -0500 Received: by mail-vk1-f193.google.com with SMTP id b129so845152vka.4 for ; Fri, 24 Jan 2020 10:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=k9IbFX230h+2YJkS//36Bone21Vlk4mvmv7ukUtwlrg=; b=DAXjtZMQxree0LJO6fobOGURErQ0ju/inC8/fsZF0REb/T72vFjS7K0OhD0Y+lf2gK lMPRw+NUBnFlszUuo1F/uLO7RoYDcq6CWVZ5BnXUxTgouURwMS2+PEcc6JnpM+rHv1lO Q+wAY4Fvcu1Tt5CmyotNaXTNXtiYUbF2NVpmLkfbcJaUW2KVvuXLwarJvxsy/CmqxCzc lF0yf3bRXw9OsO6bwUqmrWWhymuzSbWXcS4C1Yxq5LfRRbxfXuwQcB+KudGLC8h6tVTk XaEai9+ATEb46ZczpqDbhaWNgUERSjbEX/rDpyXjd+8ejWhSyzbE4tkDbrAZZHxu2to0 jFjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=k9IbFX230h+2YJkS//36Bone21Vlk4mvmv7ukUtwlrg=; b=SuiJHoLdMiRLZI97I37El/5Damuy1gmsJzRB2w0gVOQqNAGSz64LV6+Ib9xxGPjqJ+ MK6+yl/wY3PJ7tVUlJHjN0r5PKSUAsFomgduY6/wjrVtwaJ7QeKQHhXazjksB0FQO6AV MrKaX/ktehBLeG1gbnFBPxoiS/c0bPHFEg+4qP6jysRUwExOVwmdYEP1EcZR4O7w8oxj oDZdJp4hGry21CRRGCDLtFxIYAK3Px1wq8sSdQsQ+YeGguWltKuDWw/dUIq8E0juV0kK 6V03UlnPCmnt8PUHtK4Lr/EW2PXZI6Zz39Fwqr/Unni0O+k/e/jedFXS4QlvLI5lQEQe Nv1A== X-Gm-Message-State: APjAAAUuCiADwQHeh2uZir8A0rRlj1BXyIYFw7I21kevECf6VvLMfLtz WvGxXsDWC75RKViz+NmASLlIbiDWv3CB9xF4acxPY09grdklUg== X-Received: by 2002:a1f:db81:: with SMTP id s123mr2936809vkg.45.1579892048933; Fri, 24 Jan 2020 10:54:08 -0800 (PST) MIME-Version: 1.0 References: <20200123180436.99487-1-bgardon@google.com> <20200123180436.99487-11-bgardon@google.com> In-Reply-To: From: Ben Gardon Date: Fri, 24 Jan 2020 10:53:57 -0800 Message-ID: Subject: Re: [PATCH v4 10/10] KVM: selftests: Move memslot 0 above KVM internal memslots To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, Cannon Matthews , Peter Xu , Andrew Jones , Peter Shier , Oliver Upton Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 24, 2020 at 1:01 AM Paolo Bonzini wrote: > > On 23/01/20 19:04, Ben Gardon wrote: > > KVM creates internal memslots between 3 and 4 GiB paddrs on the first > > vCPU creation. If memslot 0 is large enough it collides with these > > memslots an causes vCPU creation to fail. Instead of creating memslot 0 > > at paddr 0, start it 4G into the guest physical address space. > > > > Signed-off-by: Ben Gardon > > --- > > tools/testing/selftests/kvm/lib/kvm_util.c | 11 +++++++---- > > 1 file changed, 7 insertions(+), 4 deletions(-) > > This breaks all tests for me: > > $ ./state_test > Testing guest mode: PA-bits:ANY, VA-bits:48, 4K pages > Guest physical address width detected: 46 > ==== Test Assertion Failure ==== > lib/x86_64/processor.c:580: false > pid=4873 tid=4873 - Success > 1 0x0000000000409996: addr_gva2gpa at processor.c:579 > 2 0x0000000000406a38: addr_gva2hva at kvm_util.c:1636 > 3 0x000000000041036c: kvm_vm_elf_load at elf.c:192 > 4 0x0000000000409ea9: vm_create_default at processor.c:829 > 5 0x0000000000400f6f: main at state_test.c:132 > 6 0x00007f21bdf90494: ?? ??:0 > 7 0x0000000000401287: _start at ??:? > No mapping for vm virtual address, gva: 0x400000 Uh oh, I obviously did not test this patch adequately. My apologies. I'll send another version of this patch after I've had time to test it better. The memslots between 3G and 4G are also somewhat x86 specific, so maybe this code should be elsewhere. > > Memslot 0 should not be too large, so this patch should not be needed. I found that 3GB was not sufficient for memslot zero in my testing because it needs to contain both the stack for every vCPU and the page tables for the VM. When I ran with 416 vCPUs and of 1.6TB of total ram, memslot zero needed to be substantially larger than 3G. Just the 4K guest PTEs required to map 4G per-vCPU for 416 vCPUs require (((416 * (4<<30)) / 4096) * 8) / (1<<30) = 3.25GB of memory. I suppose another slot could be used for the page tables, but that would complicate the implementation of any tests that want to run large VMs substantially. > > Paolo >