From patchwork Thu Jul 1 15:40:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 12354445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5140C11F64 for ; Thu, 1 Jul 2021 15:43:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8163C61407 for ; Thu, 1 Jul 2021 15:43:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8163C61407 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1vZdE7mqFHYavvOsixJvzTtBAZxwugHlVrsqLc+v6YQ=; b=tW083EWgeAmrPK fC4zXoRQ5ZzABWWGx6iekZ3iQCvV5B1yKmpKcZ7whi78DNwLXEd4gc43NpN+03PXCJpeCw11dtj27 3HJq/9+wJhmaHdSzFR+WrBfW1JSIP8nEapFx3HoYt4q3xIiIRTWF4mUIYATenU9pC33OL0B8GiVQd mjbCftihuG8uUSW2Cq2VXs2KAyK1paHRUS/1W6hQryE3IKageTeKm2abFM06zFkDuDx0Ipt8Iqo7X Y1mocfApGmPHfPbbQyNTHTB1RR3QQfrl7m+eW9VxEJo28GhrETjUwDV/Cysaf1WbkN/27O24HIMVe RSVhL525iuWiZ35ieRbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyyoY-000HaO-Ns; Thu, 01 Jul 2021 15:41:18 +0000 Received: from smtp-out1.suse.de ([195.135.220.28]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lyyoS-000HWo-QT for linux-arm-kernel@lists.infradead.org; Thu, 01 Jul 2021 15:41:15 +0000 Received: from imap.suse.de (imap-alt.suse-dmz.suse.de [192.168.254.47]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A491022891; Thu, 1 Jul 2021 15:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1625154068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=upovNwSZjv8f/iecsKALo/k8SCqL9R0LoxKlal4MHxw=; b=b4fYRKsHielTGsj+p0iJjnZfPn8+LTBhqB6ZyhTEUT9lDbF2wSVPpn6+4aTMKANIhTHdkw VgRt3j0/5duL08x9ABYMvZv+/vYaznkIaqmekSXYgQUAC+25fSOuVe1nsIuJwvXQ4zTv5z 8mX/m1WcA9MsMHqfBDrh25S2ifLzPi8= Received: from imap3-int (imap-alt.suse-dmz.suse.de [192.168.254.47]) by imap.suse.de (Postfix) with ESMTP id 1D66011CD5; Thu, 1 Jul 2021 15:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1625154068; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=upovNwSZjv8f/iecsKALo/k8SCqL9R0LoxKlal4MHxw=; b=b4fYRKsHielTGsj+p0iJjnZfPn8+LTBhqB6ZyhTEUT9lDbF2wSVPpn6+4aTMKANIhTHdkw VgRt3j0/5duL08x9ABYMvZv+/vYaznkIaqmekSXYgQUAC+25fSOuVe1nsIuJwvXQ4zTv5z 8mX/m1WcA9MsMHqfBDrh25S2ifLzPi8= Received: from director2.suse.de ([192.168.254.72]) by imap3-int with ESMTPSA id lUxpBRTi3WAOFwAALh3uQQ (envelope-from ); Thu, 01 Jul 2021 15:41:08 +0000 From: Juergen Gross To: linux-kernel@vger.kernel.org, x86@kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Juergen Gross , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Jonathan Corbet , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu Subject: [PATCH 0/6] x86/kvm: add boot parameters for max vcpu configs Date: Thu, 1 Jul 2021 17:40:59 +0200 Message-Id: <20210701154105.23215-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210701_084113_076201_70B9F1C2 X-CRM114-Status: GOOD ( 14.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to be able to have a single kernel for supporting even huge numbers of vcpus per guest some arrays should be sized dynamically. The easiest way to do that is to add boot parameters for the maximum number of vcpus and the highest supported vcpu-id overwriting the normal default. This patch series is doing that for x86. The same scheme can be easily adapted to other architectures, but I don't want to do that in the first iteration. In the long term I'd suggest to have a per-guest setting of the two parameters allowing to spare some memory for smaller guests. OTOH this would require new ioctl()s and respective qemu modifications, so I let those away for now. I've tested the series not to break normal guest operation and the new parameters to be effective on x86. For Arm64 I did a compile test only. Juergen Gross (6): x86/kvm: fix vcpu-id indexed array sizes x86/kvm: remove non-x86 stuff from arch/x86/kvm/ioapic.h x86/kvm: add boot parameter for maximum vcpu-id x86/kvm: introduce per cpu vcpu masks kvm: allocate vcpu pointer array separately x86/kvm: add boot parameter for setting max number of vcpus per guest .../admin-guide/kernel-parameters.txt | 18 +++++++ arch/arm64/kvm/arm.c | 28 +++++++++-- arch/x86/include/asm/kvm_host.h | 22 ++++++--- arch/x86/kvm/hyperv.c | 25 +++++++--- arch/x86/kvm/ioapic.c | 14 +++++- arch/x86/kvm/ioapic.h | 8 +-- arch/x86/kvm/irq_comm.c | 9 +++- arch/x86/kvm/x86.c | 49 ++++++++++++++++++- include/linux/kvm_host.h | 17 ++++++- 9 files changed, 160 insertions(+), 30 deletions(-)