From patchwork Fri Jan 24 15:30:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11350581 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1987A924 for ; Fri, 24 Jan 2020 15:32:23 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 E92B920838 for ; Fri, 24 Jan 2020 15:32:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="EQUAlM3/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E92B920838 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vW-0006mm-DD; Fri, 24 Jan 2020 15:31:18 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vV-0006mh-Gn for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:17 +0000 X-Inumbo-ID: 9024146c-3ebe-11ea-b833-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9024146c-3ebe-11ea-b833-bc764e2007e4; Fri, 24 Jan 2020 15:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879878; x=1611415878; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=a1Frxf5HPTwRUTP+o9zS5og7PNjKmC3n8xlOOMifbFI=; b=EQUAlM3/hRzNjVwvK5M3sbPRft6+6XaKLTzAvVDpPmRMpreWEpT51v3f T0/B2dxscNjITNdJmzM8EBiWAnnp5jf7bl44cWq9LR4t1xIwoB/bU/F2k //3+TrTG4wkKRF1NqnBnzHTaWNXXFs+WcDDZaXq72P7Kf/atDtwjzfino Y=; IronPort-SDR: WcgEh7Cbza+JJKAP0CIMkQD7/c1vnPcySj+mzXWUfgd2kZ+tXFsITLUV6uVL9aZmnDlocvGYwF DkpasRakigyQ== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="13955559" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-859fe132.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 24 Jan 2020 15:31:16 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-859fe132.us-west-2.amazon.com (Postfix) with ESMTPS id A648D221CA8; Fri, 24 Jan 2020 15:31:14 +0000 (UTC) Received: from EX13D32EUC001.ant.amazon.com (10.43.164.159) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:14 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUC001.ant.amazon.com (10.43.164.159) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:13 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:10 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:30:58 +0000 Message-ID: <20200124153103.18321-3-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 2/7] x86 / hvm: add domain_relinquish_resources() method X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Wei Liu , Andrew Cooper , Paul Durrant , Jun Nakajima , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" There are two functions in hvm.c to deal with tear-down and a domain: hvm_domain_relinquish_resources() and hvm_domain_destroy(). However, only the latter has an associated method in 'hvm_funcs'. This patch adds a method for the former. A subsequent patch will define a VMX implementation. Signed-off-by: Paul Durrant Acked-by: Jan Beulich --- Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: Jun Nakajima Cc: Kevin Tian v2: - Make the new method optional and make it an alternative_vcall --- xen/arch/x86/hvm/hvm.c | 3 +++ xen/include/asm-x86/hvm/hvm.h | 1 + 2 files changed, 4 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index d899594888..6333ae6aba 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -716,6 +716,9 @@ int hvm_domain_initialise(struct domain *d) void hvm_domain_relinquish_resources(struct domain *d) { + if ( hvm_funcs.domain_relinquish_resources ) + alternative_vcall(hvm_funcs.domain_relinquish_resources, d); + if ( hvm_funcs.nhvm_domain_relinquish_resources ) hvm_funcs.nhvm_domain_relinquish_resources(d); diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index 09793c12e9..9eab1d7493 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -107,6 +107,7 @@ struct hvm_function_table { * Initialise/destroy HVM domain/vcpu resources */ int (*domain_initialise)(struct domain *d); + void (*domain_relinquish_resources)(struct domain *d); void (*domain_destroy)(struct domain *d); int (*vcpu_initialise)(struct vcpu *v); void (*vcpu_destroy)(struct vcpu *v); From patchwork Fri Jan 24 15:30:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11350597 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6282C924 for ; Fri, 24 Jan 2020 15:33:29 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 3ED3820838 for ; Fri, 24 Jan 2020 15:33:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="GbiJTFTU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3ED3820838 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vi-0006px-Gs; Fri, 24 Jan 2020 15:31:30 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vh-0006pe-LO for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:29 +0000 X-Inumbo-ID: 91edc874-3ebe-11ea-8032-12813bfff9fa Received: from smtp-fw-2101.amazon.com (unknown [72.21.196.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 91edc874-3ebe-11ea-8032-12813bfff9fa; Fri, 24 Jan 2020 15:31:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879882; x=1611415882; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sxPnPVoRAvywpCa7LpMqm/5kHF3lOXD/ctRFVIMS828=; b=GbiJTFTU0tCrMGQflbSo9JZeH7f6d+Q8K5mEzvbtPVTj6IrqnplpfwgC bQ7uvpYAPjcZvcul3lUikSbndydB+xoAejIpx9k9XfURv02YTLfi2daFD JUvGzHV+doLg5ECDtdUEcEsX3qWWIz9LI8dtosii4wOV8aQwRKswky3XU U=; IronPort-SDR: DJMXuMG0lyhcTByMTyve91pr8Vjzo2AV9M5u+GSKATXi4BcsJSrPSceSunrtig7WO8NPhJKLDL y4Cl88A+211A== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="14030541" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2c-87a10be6.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-2101.iad2.amazon.com with ESMTP; 24 Jan 2020 15:31:19 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2c-87a10be6.us-west-2.amazon.com (Postfix) with ESMTPS id C09CBA07AC; Fri, 24 Jan 2020 15:31:17 +0000 (UTC) Received: from EX13D32EUB004.ant.amazon.com (10.43.166.212) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:17 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUB004.ant.amazon.com (10.43.166.212) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:16 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:13 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:30:59 +0000 Message-ID: <20200124153103.18321-4-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 3/7] x86 / hvm: make domain_destroy() method optional X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Andrew Cooper , Paul Durrant , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This method is currently empty for SVM so make it optional and, while in the neighbourhood, make it an alternative_vcall(). Signed-off-by: Paul Durrant Acked-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: George Dunlap v4: - New in v4 (disaggregated from v3 patch #3) --- xen/arch/x86/hvm/hvm.c | 4 +++- xen/arch/x86/hvm/svm/svm.c | 5 ----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 6333ae6aba..0b93609a82 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -747,7 +747,9 @@ void hvm_domain_destroy(struct domain *d) hvm_destroy_cacheattr_region_list(d); - hvm_funcs.domain_destroy(d); + if ( hvm_funcs.domain_destroy ) + alternative_vcall(hvm_funcs.domain_destroy, d); + rtc_deinit(d); stdvga_deinit(d); vioapic_deinit(d); diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index b1c376d455..b7f67f9f03 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1155,10 +1155,6 @@ static int svm_domain_initialise(struct domain *d) return 0; } -static void svm_domain_destroy(struct domain *d) -{ -} - static int svm_vcpu_initialise(struct vcpu *v) { int rc; @@ -2425,7 +2421,6 @@ static struct hvm_function_table __initdata svm_function_table = { .cpu_up = svm_cpu_up, .cpu_down = svm_cpu_down, .domain_initialise = svm_domain_initialise, - .domain_destroy = svm_domain_destroy, .vcpu_initialise = svm_vcpu_initialise, .vcpu_destroy = svm_vcpu_destroy, .save_cpu_ctxt = svm_save_vmcb_ctxt, From patchwork Fri Jan 24 15:31:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11350587 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A13D2924 for ; Fri, 24 Jan 2020 15:32:50 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 7E054208C4 for ; Fri, 24 Jan 2020 15:32:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="EiUdNo8T" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7E054208C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vw-0006w4-SY; Fri, 24 Jan 2020 15:31:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0vv-0006va-Ot for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:43 +0000 X-Inumbo-ID: 9f374e6b-3ebe-11ea-8032-12813bfff9fa Received: from smtp-fw-6002.amazon.com (unknown [52.95.49.90]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9f374e6b-3ebe-11ea-8032-12813bfff9fa; Fri, 24 Jan 2020 15:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879903; x=1611415903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jWP/Kr2Ts6Val7nfm7XrDb112aC13m4+y12u2fDJXsQ=; b=EiUdNo8TQYoGVJSM0wpNsE5OVJbfK33Mmsqu+qJN5O3X810KvO4e0oof SAgCpnUnUPdOfnuvfvOmvKJK0OZljKPte8If7HeOu63DS7Iq8h5hjNaEb fzq23kSQ6Ed+vgiuOOb839TfMju9FQpN49zSFbY4CI+F0Pqk4Whf4rMbL s=; IronPort-SDR: nlTaec1g66iGDHuWM/6HZGFC/JcTcfpbwaJTUaJf4xXrQ3iHdVmw3BT367krJvP1doAqqcjTcK 4pyrkTzQ4fDA== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="13118144" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-4ff6265a.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 24 Jan 2020 15:31:41 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2b-4ff6265a.us-west-2.amazon.com (Postfix) with ESMTPS id C4029A2100; Fri, 24 Jan 2020 15:31:37 +0000 (UTC) Received: from EX13D32EUC001.ant.amazon.com (10.43.164.159) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:20 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUC001.ant.amazon.com (10.43.164.159) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:19 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:16 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:31:00 +0000 Message-ID: <20200124153103.18321-5-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 4/7] x86 / vmx: move teardown from domain_destroy()... X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Jun Nakajima , Wei Liu , Andrew Cooper , Paul Durrant , George Dunlap , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" ... to domain_relinquish_resources(). The teardown code frees the APICv page. This does not need to be done late so do it in domain_relinquish_resources() rather than domain_destroy(). Signed-off-by: Paul Durrant --- Cc: Jun Nakajima Cc: Kevin Tian Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: George Dunlap v4: - New in v4 (disaggregated from v3 patch #3) --- xen/arch/x86/hvm/vmx/vmx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index b262d38a7c..606f3dc2eb 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -419,7 +419,7 @@ static int vmx_domain_initialise(struct domain *d) return 0; } -static void vmx_domain_destroy(struct domain *d) +static void vmx_domain_relinquish_resources(struct domain *d) { if ( !has_vlapic(d) ) return; @@ -2240,7 +2240,7 @@ static struct hvm_function_table __initdata vmx_function_table = { .cpu_up_prepare = vmx_cpu_up_prepare, .cpu_dead = vmx_cpu_dead, .domain_initialise = vmx_domain_initialise, - .domain_destroy = vmx_domain_destroy, + .domain_relinquish_resources = vmx_domain_relinquish_resources, .vcpu_initialise = vmx_vcpu_initialise, .vcpu_destroy = vmx_vcpu_destroy, .save_cpu_ctxt = vmx_save_vmcs_ctxt, From patchwork Fri Jan 24 15:31:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11350589 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E02C924 for ; Fri, 24 Jan 2020 15:32:53 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 5AA2720838 for ; Fri, 24 Jan 2020 15:32:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="LxYPdoxC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5AA2720838 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0w7-00070u-LN; Fri, 24 Jan 2020 15:31:55 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0w6-00070Q-O2 for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:54 +0000 X-Inumbo-ID: a5f5290c-3ebe-11ea-8032-12813bfff9fa Received: from smtp-fw-9101.amazon.com (unknown [207.171.184.25]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a5f5290c-3ebe-11ea-8032-12813bfff9fa; Fri, 24 Jan 2020 15:31:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879915; x=1611415915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0O9XWa6PMSsPO7G+77ZbS/9zJksGKayRB8cqOasAY18=; b=LxYPdoxCbBJ3kqj7dokL08dQTIWGJp8Ub1M1EIqaOiibVb2F7yZpTwl9 GL7+5hdZWLhDIqYjT9S6c0QT/RMzcqbgXRUW5QdKNsIRDDQdSYdsLhNva 6FgBLQgoLjlk8bqYarXYA1zbIDPjBgCmX3K3ns4wLG2kAthyxjoPTUTQq A=; IronPort-SDR: AOKaeCaOnPK00bWEz1iV4yK9cn+3o3TTicpOQ7M+6hlwBfMXX7Q4a2w7zdV0+pGp0qkR2x8F8V YaBCX1OwveYA== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="12427568" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2a-e7be2041.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP; 24 Jan 2020 15:31:41 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-e7be2041.us-west-2.amazon.com (Postfix) with ESMTPS id B8BCBA21D2; Fri, 24 Jan 2020 15:31:39 +0000 (UTC) Received: from EX13D32EUC004.ant.amazon.com (10.43.164.121) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:24 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUC004.ant.amazon.com (10.43.164.121) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:23 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:20 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:31:01 +0000 Message-ID: <20200124153103.18321-6-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 5/7] mm: make MEMF_no_refcount pages safe to assign X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Paul Durrant , Ian Jackson , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently it is unsafe to assign a domheap page allocated with MEMF_no_refcount to a domain because the domain't 'tot_pages' will not be incremented, but will be decrement when the page is freed (since free_domheap_pages() has no way of telling that the increment was skipped). This patch allocates a new 'count_info' bit for a PGC_no_refcount flag which is then used to mark domheap pages allocated with MEMF_no_refcount. This then allows free_domheap_pages() to skip decrementing tot_pages when appropriate and hence makes the pages safe to assign. NOTE: The patch sets MEMF_no_refcount directly in alloc_domheap_pages() rather than in assign_pages() because the latter is called with MEMF_no_refcount by memory_exchange() as an optimization, to avoid too many calls to domain_adjust_tot_pages() (which acquires and releases the global 'heap_lock'). Signed-off-by: Paul Durrant --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Wei Liu Cc: Volodymyr Babchuk Cc: "Roger Pau Monné" v4: - New in v4 --- xen/common/page_alloc.c | 39 ++++++++++++++++++++++++++++----------- xen/include/asm-arm/mm.h | 5 ++++- xen/include/asm-x86/mm.h | 7 +++++-- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 919a270587..6103f14a4e 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -460,6 +460,9 @@ unsigned long domain_adjust_tot_pages(struct domain *d, long pages) { long dom_before, dom_after, dom_claimed, sys_before, sys_after; + if ( !pages ) + goto out; + ASSERT(spin_is_locked(&d->page_alloc_lock)); d->tot_pages += pages; @@ -1389,6 +1392,8 @@ static void free_heap_pages( for ( i = 0; i < (1 << order); i++ ) { + ASSERT(!(pg[i].count_info & PGC_no_refcount)); + /* * Cannot assume that count_info == 0, as there are some corner cases * where it isn't the case and yet it isn't a bug: @@ -2314,11 +2319,6 @@ struct page_info *alloc_domheap_pages( if ( memflags & MEMF_no_owner ) memflags |= MEMF_no_refcount; - else if ( (memflags & MEMF_no_refcount) && d ) - { - ASSERT(!(memflags & MEMF_no_refcount)); - return NULL; - } if ( !dma_bitsize ) memflags &= ~MEMF_no_dma; @@ -2331,11 +2331,20 @@ struct page_info *alloc_domheap_pages( memflags, d)) == NULL)) ) return NULL; - if ( d && !(memflags & MEMF_no_owner) && - assign_pages(d, pg, order, memflags) ) + if ( d && !(memflags & MEMF_no_owner) ) { - free_heap_pages(pg, order, memflags & MEMF_no_scrub); - return NULL; + if ( assign_pages(d, pg, order, memflags) ) + { + free_heap_pages(pg, order, memflags & MEMF_no_scrub); + return NULL; + } + if ( memflags & MEMF_no_refcount ) + { + unsigned long i; + + for ( i = 0; i < (1 << order); i++ ) + pg[i].count_info |= PGC_no_refcount; + } } return pg; @@ -2368,24 +2377,32 @@ void free_domheap_pages(struct page_info *pg, unsigned int order) if ( likely(d) && likely(d != dom_cow) ) { + long pages = 0; + /* NB. May recursively lock from relinquish_memory(). */ spin_lock_recursive(&d->page_alloc_lock); for ( i = 0; i < (1 << order); i++ ) { + unsigned long count_info = pg[i].count_info; + if ( pg[i].u.inuse.type_info & PGT_count_mask ) { printk(XENLOG_ERR "pg[%u] MFN %"PRI_mfn" c=%#lx o=%u v=%#lx t=%#x\n", i, mfn_x(page_to_mfn(pg + i)), - pg[i].count_info, pg[i].v.free.order, + count_info, pg[i].v.free.order, pg[i].u.free.val, pg[i].tlbflush_timestamp); BUG(); } arch_free_heap_page(d, &pg[i]); + if ( count_info & PGC_no_refcount ) + pg[i].count_info &= ~PGC_no_refcount; + else + pages--; } - drop_dom_ref = !domain_adjust_tot_pages(d, -(1 << order)); + drop_dom_ref = !domain_adjust_tot_pages(d, pages); spin_unlock_recursive(&d->page_alloc_lock); diff --git a/xen/include/asm-arm/mm.h b/xen/include/asm-arm/mm.h index 333efd3a60..1076cc9713 100644 --- a/xen/include/asm-arm/mm.h +++ b/xen/include/asm-arm/mm.h @@ -119,9 +119,12 @@ struct page_info #define PGC_state_offlined PG_mask(2, 9) #define PGC_state_free PG_mask(3, 9) #define page_state_is(pg, st) (((pg)->count_info&PGC_state) == PGC_state_##st) +/* Page is not reference counted */ +#define _PGC_no_refcount PG_shift(10) +#define PGC_no_refcount PG_mask(1, 10) /* Count of references to this frame. */ -#define PGC_count_width PG_shift(9) +#define PGC_count_width PG_shift(10) #define PGC_count_mask ((1UL<count_info&PGC_state) == PGC_state_##st) +/* Page is not reference counted */ +#define _PGC_no_refcount PG_shift(10) +#define PGC_no_refcount PG_mask(1, 10) - /* Count of references to this frame. */ -#define PGC_count_width PG_shift(9) +/* Count of references to this frame. */ +#define PGC_count_width PG_shift(10) #define PGC_count_mask ((1UL< X-Patchwork-Id: 11350599 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D169924 for ; Fri, 24 Jan 2020 15:33:34 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 79A6320838 for ; Fri, 24 Jan 2020 15:33:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="P81SGzqv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 79A6320838 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0w4-0006yy-99; Fri, 24 Jan 2020 15:31:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0w3-0006yi-Nm for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:51 +0000 X-Inumbo-ID: 9fb133a6-3ebe-11ea-aecd-bc764e2007e4 Received: from smtp-fw-6001.amazon.com (unknown [52.95.48.154]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 9fb133a6-3ebe-11ea-aecd-bc764e2007e4; Fri, 24 Jan 2020 15:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879903; x=1611415903; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oMAppv56KAfQ4kG90bZsQ7GWRcBbT/ckuNqYoVVoRUo=; b=P81SGzqvHUvmMPRxtvUrK4AHgJh4fKhEwVSoOFc/9O7iva1q/rrqiPQV C/PYRKk6Ckxog6JbSYTYe7dQgxUXa4yFhsjQipZUp7C4rzaFgrtvCUGAT d2maKFKUnPzUz8dxV3q/hRRLNRng/wwJnvAs7LYGpvGJUYhMzQxRzK4gR o=; IronPort-SDR: aY36YlnjNi0Jjuto+xQ+UYxvQSo8r/WRRZxXs8VSNuIC3VBYUqNKtH4MfMsCSayOLqtHUIq8bd HmNOXy8ebUag== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="14564178" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-53356bf6.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 24 Jan 2020 15:31:41 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2a-53356bf6.us-west-2.amazon.com (Postfix) with ESMTPS id E029FA2316; Fri, 24 Jan 2020 15:31:40 +0000 (UTC) Received: from EX13D32EUC003.ant.amazon.com (10.43.164.24) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:28 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUC003.ant.amazon.com (10.43.164.24) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:26 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:24 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:31:02 +0000 Message-ID: <20200124153103.18321-7-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 6/7] x86 / vmx: use a MEMF_no_refcount domheap page for APIC_DEFAULT_PHYS_BASE X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Jun Nakajima , Wei Liu , Andrew Cooper , Paul Durrant , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" vmx_alloc_vlapic_mapping() currently contains some very odd looking code that allocates a MEMF_no_owner domheap page and then shares with the guest as if it were a xenheap page. This then requires vmx_free_vlapic_mapping() to call a special function in the mm code: free_shared_domheap_page(). By using a MEMF_no_refcount domheap page instead, the odd looking code in vmx_alloc_vlapic_mapping() can simply use get_page_and_type() to set up a writable mapping before insertion in the P2M and vmx_free_vlapic_mapping() can simply release the page using put_page_alloc_ref() followed by put_page_and_type(). This then allows free_shared_domheap_page() to be purged. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Jun Nakajima Cc: Kevin Tian Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" v4: - Use a MEMF_no_refcount page rather than a 'normal' page v2: - Set an initial value for max_pages rather than avoiding the check in assign_pages() - Make domain_destroy() optional --- xen/arch/x86/hvm/vmx/vmx.c | 21 ++++++++++++++++++--- xen/arch/x86/mm.c | 10 ---------- xen/include/asm-x86/mm.h | 2 -- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 606f3dc2eb..7423d2421b 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -3028,12 +3028,22 @@ static int vmx_alloc_vlapic_mapping(struct domain *d) if ( !cpu_has_vmx_virtualize_apic_accesses ) return 0; - pg = alloc_domheap_page(d, MEMF_no_owner); + pg = alloc_domheap_page(d, MEMF_no_refcount); if ( !pg ) return -ENOMEM; + + if ( !get_page_and_type(pg, d, PGT_writable_page) ) + { + /* + * The domain can't possibly know about this page yet, so failure + * here is a clear indication of something fishy going on. + */ + domain_crash(d); + return -ENODATA; + } + mfn = page_to_mfn(pg); clear_domain_page(mfn); - share_xen_page_with_guest(pg, d, SHARE_rw); d->arch.hvm.vmx.apic_access_mfn = mfn; return set_mmio_p2m_entry(d, paddr_to_pfn(APIC_DEFAULT_PHYS_BASE), mfn, @@ -3047,7 +3057,12 @@ static void vmx_free_vlapic_mapping(struct domain *d) d->arch.hvm.vmx.apic_access_mfn = _mfn(0); if ( !mfn_eq(mfn, _mfn(0)) ) - free_shared_domheap_page(mfn_to_page(mfn)); + { + struct page_info *pg = mfn_to_page(mfn); + + put_page_alloc_ref(pg); + put_page_and_type(pg); + } } static void vmx_install_vlapic_mapping(struct vcpu *v) diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 654190e9e9..2a6d2e8af9 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -496,16 +496,6 @@ void share_xen_page_with_guest(struct page_info *page, struct domain *d, spin_unlock(&d->page_alloc_lock); } -void free_shared_domheap_page(struct page_info *page) -{ - put_page_alloc_ref(page); - if ( !test_and_clear_bit(_PGC_xen_heap, &page->count_info) ) - ASSERT_UNREACHABLE(); - page->u.inuse.type_info = 0; - page_set_owner(page, NULL); - free_domheap_page(page); -} - void make_cr3(struct vcpu *v, mfn_t mfn) { struct domain *d = v->domain; diff --git a/xen/include/asm-x86/mm.h b/xen/include/asm-x86/mm.h index e75feea15e..036d7ac22f 100644 --- a/xen/include/asm-x86/mm.h +++ b/xen/include/asm-x86/mm.h @@ -320,8 +320,6 @@ struct page_info #define maddr_get_owner(ma) (page_get_owner(maddr_to_page((ma)))) -extern void free_shared_domheap_page(struct page_info *page); - #define frame_table ((struct page_info *)FRAMETABLE_VIRT_START) extern unsigned long max_page; extern unsigned long total_pages; From patchwork Fri Jan 24 15:31:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11350593 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EE82924 for ; Fri, 24 Jan 2020 15:32:57 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 EF1CC20838 for ; Fri, 24 Jan 2020 15:32:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="MwhCW9AN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF1CC20838 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0wD-00074d-B7; Fri, 24 Jan 2020 15:32:01 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iv0wB-00073l-OA for xen-devel@lists.xenproject.org; Fri, 24 Jan 2020 15:31:59 +0000 X-Inumbo-ID: a5a1f8bb-3ebe-11ea-8032-12813bfff9fa Received: from smtp-fw-33001.amazon.com (unknown [207.171.190.10]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id a5a1f8bb-3ebe-11ea-8032-12813bfff9fa; Fri, 24 Jan 2020 15:31:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1579879915; x=1611415915; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ahbKDvUHG0beABwkwLlarH9Not4uFWdN3xL+SF4P2bA=; b=MwhCW9ANh6wiqHMD/7U2H4t1JY9rXausShm4hiZ442GQWjUiSaUtyl1Q C47LMIS3+USqmRal+X53ADxVzTPO6PDorHmENLPiepgn2PNBmTm3Ib0ZE dVD2I0rKOMuLjGk3jF0oosKbUxVEAutODdfg9LjUzJyOKsWA3I7nEkCJk E=; IronPort-SDR: nkR1m4H4lo/gvQus4d4RLEEkCjsqV+LyHkJy3QouOoHEZZU+yrAa47EZf/q69y/qEc+OpuWEV9 NnnM0UMJFpVA== X-IronPort-AV: E=Sophos;i="5.70,358,1574121600"; d="scan'208";a="22196949" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-baacba05.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 24 Jan 2020 15:31:44 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-baacba05.us-west-2.amazon.com (Postfix) with ESMTPS id 08678A21B6; Fri, 24 Jan 2020 15:31:42 +0000 (UTC) Received: from EX13D32EUB002.ant.amazon.com (10.43.166.114) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Fri, 24 Jan 2020 15:31:32 +0000 Received: from EX13MTAUWB001.ant.amazon.com (10.43.161.207) by EX13D32EUB002.ant.amazon.com (10.43.166.114) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Fri, 24 Jan 2020 15:31:30 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.161.249) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Fri, 24 Jan 2020 15:31:27 +0000 From: Paul Durrant To: Date: Fri, 24 Jan 2020 15:31:03 +0000 Message-ID: <20200124153103.18321-8-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200124153103.18321-1-pdurrant@amazon.com> References: <20200124153103.18321-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v4 7/7] mm: remove donate_page() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Paul Durrant , Ian Jackson , Volodymyr Babchuk , =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" This function appears to have no callers. Signed-off-by: Paul Durrant Acked-by: George Dunlap Acked-by: Julien Grall --- Cc: Stefano Stabellini Cc: Julien Grall Cc: Volodymyr Babchuk Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Wei Liu Cc: "Roger Pau Monné" v4: - New in v4 --- xen/arch/arm/mm.c | 6 ------ xen/arch/x86/mm.c | 41 ----------------------------------------- xen/include/xen/mm.h | 2 -- 3 files changed, 49 deletions(-) diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c index 4d6c971f37..727107eefa 100644 --- a/xen/arch/arm/mm.c +++ b/xen/arch/arm/mm.c @@ -1353,12 +1353,6 @@ void arch_dump_shared_mem_info(void) { } -int donate_page(struct domain *d, struct page_info *page, unsigned int memflags) -{ - ASSERT_UNREACHABLE(); - return -ENOSYS; -} - int steal_page( struct domain *d, struct page_info *page, unsigned int memflags) { diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 2a6d2e8af9..67351798c7 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -4174,47 +4174,6 @@ long do_mmu_update( } #endif /* CONFIG_PV */ -int donate_page( - struct domain *d, struct page_info *page, unsigned int memflags) -{ - const struct domain *owner = dom_xen; - - spin_lock(&d->page_alloc_lock); - - if ( is_xen_heap_page(page) || ((owner = page_get_owner(page)) != NULL) ) - goto fail; - - if ( d->is_dying ) - goto fail; - - if ( page->count_info & ~(PGC_allocated | 1) ) - goto fail; - - if ( !(memflags & MEMF_no_refcount) ) - { - if ( d->tot_pages >= d->max_pages ) - goto fail; - if ( unlikely(domain_adjust_tot_pages(d, 1) == 1) ) - get_knownalive_domain(d); - } - - page->count_info = PGC_allocated | 1; - page_set_owner(page, d); - page_list_add_tail(page,&d->page_list); - - spin_unlock(&d->page_alloc_lock); - return 0; - - fail: - spin_unlock(&d->page_alloc_lock); - gdprintk(XENLOG_WARNING, "Bad donate mfn %" PRI_mfn - " to d%d (owner d%d) caf=%08lx taf=%" PRtype_info "\n", - mfn_x(page_to_mfn(page)), d->domain_id, - owner ? owner->domain_id : DOMID_INVALID, - page->count_info, page->u.inuse.type_info); - return -EINVAL; -} - /* * Steal page will attempt to remove `page` from domain `d`. Upon * return, `page` will be in a state similar to the state of a page diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index 8d0ddfb60c..d0d095d9c7 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -599,8 +599,6 @@ int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp, int __must_check guest_remove_page(struct domain *d, unsigned long gmfn); int __must_check steal_page(struct domain *d, struct page_info *page, unsigned int memflags); -int __must_check donate_page(struct domain *d, struct page_info *page, - unsigned int memflags); #define RAM_TYPE_CONVENTIONAL 0x00000001 #define RAM_TYPE_RESERVED 0x00000002