From patchwork Wed Feb 12 16:09:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11378695 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 12686109A for ; Wed, 12 Feb 2020 16:10:43 +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 E361E2073C for ; Wed, 12 Feb 2020 16:10:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aFjNnTOs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E361E2073C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1j1uZu-0003Mo-7G; Wed, 12 Feb 2020 16:09:30 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1uZs-0003Mi-Cp for xen-devel@lists.xenproject.org; Wed, 12 Feb 2020 16:09:28 +0000 X-Inumbo-ID: 08b8acc4-4db2-11ea-ade5-bc764e2007e4 Received: from mail-wr1-x441.google.com (unknown [2a00:1450:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 08b8acc4-4db2-11ea-ade5-bc764e2007e4; Wed, 12 Feb 2020 16:09:23 +0000 (UTC) Received: by mail-wr1-x441.google.com with SMTP id z3so3076546wru.3 for ; Wed, 12 Feb 2020 08:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=w4/mKx/qtd0NynVOwfww2yoUw6w2UGTwgak3PQ9DLDE=; b=aFjNnTOsfQJbduTfX8S08F4A+E8kABjSFR3ZIs6lvMdExpd6s6mI67LE+0gZ2kNbau S4nu33b/QoLfi/IOUWQA3usfgsl1+/WOCZ4ZCUmrJqky7DoLNaGUj6jlvPx5QHhkx2gk 7z7J0bSQINA/CtnYPiHxNYBKibnrFaPUbLyuVNw3m/DmB4NptTPhgDL0weQiSt7fUcT7 7SDDVKh0BPTfTyji7gTvycZTi5ojKUl5abiyi+8PEFgajeOw0AZv0Fsw7QxDQvOYT9cv g2/OnGFe93+xOJjBM4euD1REqJ5RhPjQWeWgxZYKh0GdZp0ES+q7ebnzc1nH8xtcdM55 uwUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=w4/mKx/qtd0NynVOwfww2yoUw6w2UGTwgak3PQ9DLDE=; b=lb8KURgeyyidtHUhxhS/glaP6WwUhgC2xaVySwP0boh2KeLda48TMVSyJOUVUTC/T7 x/5B9/yLp+f3MZPwDWPXgPG3n3yPQlmD8pvGh0H4ZTx/uotpr5D1AYOuapXQPrwVfAqz PYshyYReG0J8/Qvk/E1XjczEBv/6pWa288WPwMqliR76NwyBm2fqDLpNbvIwiYaBj8Bd 8OM617qmjGnh3Dd3F85f9pNGKbvnRFykklB4pC/UdYeTtzqZxpMZYgDKC7Y6wENn0StC 5LepY/xZ9MNj4dQwolaEZ6RUlB95TqNvXl4zNOddfG24TBvZM0fAeZUZO1DiKgTaWL/F ik8g== X-Gm-Message-State: APjAAAU6TlkysoVjwpRmkzFZjxK+OQJUm1yFfJpjMu7XDhLz1PuaBdDF VKgJp2g/nSAn09K2U4ZqGivxj1xb X-Google-Smtp-Source: APXvYqxv6ZxvAJ8EBNiZ22MO7NLcpNYu3QGMUvJAs6bDhvDhiBz0CxVsfpR13SFygtSqm4pTJYi8DQ== X-Received: by 2002:a05:6000:10d1:: with SMTP id b17mr15768677wrx.298.1581523762841; Wed, 12 Feb 2020 08:09:22 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id o4sm1142500wrx.25.2020.02.12.08.09.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 08:09:22 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 12 Feb 2020 16:09:15 +0000 Message-Id: <20200212160918.18470-2-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212160918.18470-1-liuwe@microsoft.com> References: <20200212160918.18470-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/4] x86/hyperv: misc cleanup X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Change hv_vp_index to use uint32_t because that is what is defined in TLFS. Add "_addr" suffix to hv_do_rep_hypercall's parameters. Signed-off-by: Wei Liu Reviewed-by: Roger Pau Monné Reviewed-by: Paul Durrant --- xen/arch/x86/guest/hyperv/hyperv.c | 2 +- xen/arch/x86/guest/hyperv/private.h | 2 +- xen/include/asm-x86/guest/hyperv-hcall.h | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index 70f4cd5ae0..b7044f7193 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -31,7 +31,7 @@ struct ms_hyperv_info __read_mostly ms_hyperv; DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page); DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist); -DEFINE_PER_CPU_READ_MOSTLY(unsigned int, hv_vp_index); +DEFINE_PER_CPU_READ_MOSTLY(uint32_t, hv_vp_index); static uint64_t generate_guest_id(void) { diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h index 956eff831f..eb14ea43e5 100644 --- a/xen/arch/x86/guest/hyperv/private.h +++ b/xen/arch/x86/guest/hyperv/private.h @@ -26,6 +26,6 @@ DECLARE_PER_CPU(void *, hv_input_page); DECLARE_PER_CPU(void *, hv_vp_assist); -DECLARE_PER_CPU(unsigned int, hv_vp_index); +DECLARE_PER_CPU(uint32_t, hv_vp_index); #endif /* __XEN_HYPERV_PRIVIATE_H__ */ diff --git a/xen/include/asm-x86/guest/hyperv-hcall.h b/xen/include/asm-x86/guest/hyperv-hcall.h index 4d3b131b3a..3396caccdd 100644 --- a/xen/include/asm-x86/guest/hyperv-hcall.h +++ b/xen/include/asm-x86/guest/hyperv-hcall.h @@ -61,7 +61,8 @@ static inline uint64_t hv_do_fast_hypercall(uint16_t code, static inline uint64_t hv_do_rep_hypercall(uint16_t code, uint16_t rep_count, uint16_t varhead_size, - paddr_t input, paddr_t output) + paddr_t input_addr, + paddr_t output_addr) { uint64_t control = code; uint64_t status; @@ -71,7 +72,7 @@ static inline uint64_t hv_do_rep_hypercall(uint16_t code, uint16_t rep_count, control |= (uint64_t)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; do { - status = hv_do_hypercall(control, input, output); + status = hv_do_hypercall(control, input_addr, output_addr); if ( (status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS ) break; From patchwork Wed Feb 12 16:09:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11378699 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 317BF17F0 for ; Wed, 12 Feb 2020 16:10: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 0E31E2082F for ; Wed, 12 Feb 2020 16:10:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lJxs3jYt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E31E2082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1j1uZy-0003O9-L9; Wed, 12 Feb 2020 16:09:34 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1uZx-0003Ns-Dt for xen-devel@lists.xenproject.org; Wed, 12 Feb 2020 16:09:33 +0000 X-Inumbo-ID: 09684986-4db2-11ea-aa99-bc764e2007e4 Received: from mail-wm1-x341.google.com (unknown [2a00:1450:4864:20::341]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 09684986-4db2-11ea-aa99-bc764e2007e4; Wed, 12 Feb 2020 16:09:25 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id b17so3177847wmb.0 for ; Wed, 12 Feb 2020 08:09:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=56pHjvmS/8iVc5aFusq4dajXLO6o88TEhecDdThBVrE=; b=lJxs3jYtOldvRlBSU5bkybowGs5xu7k+fL5wkQE3M4hCjIYWkFTZpTUwCjgdOu5qJF oLsqVqY8tnm9TWyS0WTYZxb//x3lw777kt5WoLU5+1c1ICknhDNfti88cDbQc9O/JfU5 ypnz844dCaKX9LLboaMNdNyiDEBRNn+lD8mmFd/EZrxzjJbTCVNGvDwTtfJ++D6JtYJS QpyAa6qq+D9quitcgoORA1ytFzP8sXXbixNuoFGujC4/fg179bxMY8ySLN6b1FFTliB+ vuhcFPykvI+v3MTVppMGfCXbywWBJDoCb/hZZD+lkdxNKFOQNN+xtvhRUheA0uhr3TK/ wPPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=56pHjvmS/8iVc5aFusq4dajXLO6o88TEhecDdThBVrE=; b=sz5woLeqeM/k5pVgbYJB62DuXkPTOAMCsAUg42KXAz+B/BXMtQIArk/X8smzaJUJPO 6Lx+vl7faQLyhd4dML0AZzKOu9iRjn2oaNyZ4w5bSKHMJqNMqA7LRxnKmlIEaTz9d1dQ FpgWnouDrkzYlNaazmgKNQaV7CmfCnxJomwzyGhoOMJN+onQvsv03bVKVPCbU4bFvqn7 XVGy9+JLz9Xe1+IkzcBKJPSjzOrP78TEZFqTl7vG5+b9MloHiLdu+FrbeNBO7aDEhhx3 tent5/0dK53SqikviWY6rmPZ7K5oMwHUQxUqKWtxcx0Am2EX2UYk9wPNUqorBQYXtE0D KA4A== X-Gm-Message-State: APjAAAUwrSSwwHNY0kCEphIfXeXmzlOSDYS3JfY4S/UTrhnd1Gfatv2F 3TFLKFoYwAZzjaO7FWJT9Wt73CaR X-Google-Smtp-Source: APXvYqzcejQMmCuKD0cuxnlcxBaIVnCk5rf6VX+2D1gNhB97xzHFfaOsqzhIdmjs1hVrQIWArZUNnA== X-Received: by 2002:a7b:cc6a:: with SMTP id n10mr13532046wmj.170.1581523763975; Wed, 12 Feb 2020 08:09:23 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id o4sm1142500wrx.25.2020.02.12.08.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 08:09:23 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 12 Feb 2020 16:09:16 +0000 Message-Id: <20200212160918.18470-3-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212160918.18470-1-liuwe@microsoft.com> References: <20200212160918.18470-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] x86/hypervisor: pass flags to hypervisor_flush_tlb X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Hyper-V's L0 assisted flush has fine-grained control over what gets flushed. We need all the flags available to make the best decisions possible. No functional change because Xen's implementation doesn't care about what is passed to it. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hypervisor.c | 4 ++-- xen/arch/x86/guest/xen/xen.c | 2 +- xen/arch/x86/smp.c | 2 +- xen/include/asm-x86/guest/hypervisor.h | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c index 47e938e287..2724fd9bad 100644 --- a/xen/arch/x86/guest/hypervisor.c +++ b/xen/arch/x86/guest/hypervisor.c @@ -75,10 +75,10 @@ void __init hypervisor_e820_fixup(struct e820map *e820) } int hypervisor_flush_tlb(const cpumask_t *mask, const void *va, - unsigned int order) + unsigned int flags) { if ( ops.flush_tlb ) - return alternative_call(ops.flush_tlb, mask, va, order); + return alternative_call(ops.flush_tlb, mask, va, flags); return -ENOSYS; } diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c index 5d3427a713..0eb1115c4d 100644 --- a/xen/arch/x86/guest/xen/xen.c +++ b/xen/arch/x86/guest/xen/xen.c @@ -324,7 +324,7 @@ static void __init e820_fixup(struct e820map *e820) pv_shim_fixup_e820(e820); } -static int flush_tlb(const cpumask_t *mask, const void *va, unsigned int order) +static int flush_tlb(const cpumask_t *mask, const void *va, unsigned int flags) { return xen_hypercall_hvm_op(HVMOP_flush_tlbs, NULL); } diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index 9bc925616a..2df21e396a 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -260,7 +260,7 @@ void flush_area_mask(const cpumask_t *mask, const void *va, unsigned int flags) if ( cpu_has_hypervisor && !(flags & ~(FLUSH_TLB | FLUSH_TLB_GLOBAL | FLUSH_VA_VALID | FLUSH_ORDER_MASK)) && - !hypervisor_flush_tlb(mask, va, flags & FLUSH_ORDER_MASK) ) + !hypervisor_flush_tlb(mask, va, flags) ) { if ( tlb_clk_enabled ) tlb_clk_enabled = false; diff --git a/xen/include/asm-x86/guest/hypervisor.h b/xen/include/asm-x86/guest/hypervisor.h index 432e57c2a0..48d54735d2 100644 --- a/xen/include/asm-x86/guest/hypervisor.h +++ b/xen/include/asm-x86/guest/hypervisor.h @@ -35,7 +35,7 @@ struct hypervisor_ops { /* Fix up e820 map */ void (*e820_fixup)(struct e820map *e820); /* L0 assisted TLB flush */ - int (*flush_tlb)(const cpumask_t *mask, const void *va, unsigned int order); + int (*flush_tlb)(const cpumask_t *mask, const void *va, unsigned int flags); }; #ifdef CONFIG_GUEST @@ -48,11 +48,11 @@ void hypervisor_e820_fixup(struct e820map *e820); /* * L0 assisted TLB flush. * mask: cpumask of the dirty vCPUs that should be flushed. - * va: linear address to flush, or NULL for global flushes. - * order: order of the linear address pointed by va. + * va: linear address to flush, or NULL for entire address space. + * flags: flags for flushing, including the order of va. */ int hypervisor_flush_tlb(const cpumask_t *mask, const void *va, - unsigned int order); + unsigned int flags); #else @@ -65,7 +65,7 @@ static inline int hypervisor_ap_setup(void) { return 0; } static inline void hypervisor_resume(void) { ASSERT_UNREACHABLE(); } static inline void hypervisor_e820_fixup(struct e820map *e820) {} static inline int hypervisor_flush_tlb(const cpumask_t *mask, const void *va, - unsigned int order) + unsigned int flags) { return -ENOSYS; } From patchwork Wed Feb 12 16:09:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11378693 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 EC4F0109A for ; Wed, 12 Feb 2020 16:10:40 +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 C6B7E2073C for ; Wed, 12 Feb 2020 16:10:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uTqzjhbd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6B7E2073C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1j1ua4-0003Pe-0S; Wed, 12 Feb 2020 16:09:40 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1ua2-0003PM-Ct for xen-devel@lists.xenproject.org; Wed, 12 Feb 2020 16:09:38 +0000 X-Inumbo-ID: 0a39bdcc-4db2-11ea-ade5-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0a39bdcc-4db2-11ea-ade5-bc764e2007e4; Wed, 12 Feb 2020 16:09:26 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id q9so2939044wmj.5 for ; Wed, 12 Feb 2020 08:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Neo9830nXS7pOHb+tEopg55AY8hDgs4S3FCPUyPLXyc=; b=uTqzjhbdHb9xJGGlznMWGTb1+KO10EabT4tw5XrIe3eh02zPsW6EBh1BnVdolyD6eG AIGlGBPWvKYv1MTEI96D3ov1uyP+iESzcskd9jXykramPBd4RDuJebihE6hNoby8rxvv fHHkLQo3+BH4MTucB9QlLjyxWtMFXCSkCsUYU6+Neg0G4uz9a3v6NPJRHOBPM/2ihoZT nPaMdRUWE2XWBdwRf8+v43iiiGFuTxNhNB5EavOkV46r6kxXrsZNTk5A1Qo5DglXsrmD ls4g6szvx+8RCEnTUpJpJeoY35EQz6sebuTiuprtPYk5HbUMdt1ydtHDnP5yUzv+50rL 8RzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Neo9830nXS7pOHb+tEopg55AY8hDgs4S3FCPUyPLXyc=; b=ucaGFS8YLY4069zvTBHiDZsD6/6K5/1qBTpN5vxrjKfeiLgp5OxWIm+oK/CUerOsDc zFXFfaPDSpO8QIHnFviptyKYxSveJf/oXCY5IGN0/AoizFdPS5YN0WfLRTphyaPexMif Ua2H90ongjZFKVGQ1RZ1zfj9wqPhZICcSf4dxVQzqpeCwXf1CFhZ6LF5Ef0soGIIS4cN b4cIWF3dIFvIeuDPWiH4UCfPHUnXdx93lagn5Q8tIuoPlGJGuhIBQqsyKeDXMKCnA44b DCmse0y3VJy47288m0frsoxzLLpQmCNLyr1CJiU68dt1O/tZbFa1+PBp2LH81JVWRW54 SjAg== X-Gm-Message-State: APjAAAVstBCZBKAuprpBB8xO580g/yi4KolPfUS3S1/YqjeTavYhIrP+ wUPTRzbF7uePbsH6AZ/1GNzsFx4y X-Google-Smtp-Source: APXvYqypzgUZ6Pr+AaXzzaZNTLtFB9Amlm9cg/SCercxqodyxS4Nq+PtpRlpGxUXuiT7yuKrP7Ml8g== X-Received: by 2002:a7b:c5da:: with SMTP id n26mr13089439wmk.138.1581523765260; Wed, 12 Feb 2020 08:09:25 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id o4sm1142500wrx.25.2020.02.12.08.09.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 08:09:24 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 12 Feb 2020 16:09:17 +0000 Message-Id: <20200212160918.18470-4-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212160918.18470-1-liuwe@microsoft.com> References: <20200212160918.18470-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] x86/hyperv: skeleton for L0 assisted TLB flush X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Implement a basic hook for L0 assisted TLB flush. The hook needs to check if prerequisites are met. If they are not met, it returns an error number to fall back to native flushes. Introduce a new variable to indicate if hypercall page is ready. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/hyperv.c | 17 ++++++++++++ xen/arch/x86/guest/hyperv/private.h | 4 +++ xen/arch/x86/guest/hyperv/tlb.c | 41 +++++++++++++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 xen/arch/x86/guest/hyperv/tlb.c diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv/Makefile index 68170109a9..18902c33e9 100644 --- a/xen/arch/x86/guest/hyperv/Makefile +++ b/xen/arch/x86/guest/hyperv/Makefile @@ -1 +1,2 @@ obj-y += hyperv.o +obj-y += tlb.o diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c index b7044f7193..1cdc88e27c 100644 --- a/xen/arch/x86/guest/hyperv/hyperv.c +++ b/xen/arch/x86/guest/hyperv/hyperv.c @@ -33,6 +33,8 @@ DEFINE_PER_CPU_READ_MOSTLY(void *, hv_input_page); DEFINE_PER_CPU_READ_MOSTLY(void *, hv_vp_assist); DEFINE_PER_CPU_READ_MOSTLY(uint32_t, hv_vp_index); +static bool __read_mostly hv_hcall_page_ready; + static uint64_t generate_guest_id(void) { union hv_guest_os_id id = {}; @@ -119,6 +121,8 @@ static void __init setup_hypercall_page(void) BUG_ON(!hypercall_msr.enable); set_fixmap_x(FIX_X_HYPERV_HCALL, mfn << PAGE_SHIFT); + + hv_hcall_page_ready = true; } static int setup_hypercall_pcpu_arg(void) @@ -199,11 +203,24 @@ static void __init e820_fixup(struct e820map *e820) panic("Unable to reserve Hyper-V hypercall range\n"); } +static int flush_tlb(const cpumask_t *mask, const void *va, + unsigned int flags) +{ + if ( !(ms_hyperv.hints & HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED) ) + return -EOPNOTSUPP; + + if ( !hv_hcall_page_ready || !this_cpu(hv_input_page) ) + return -ENXIO; + + return hyperv_flush_tlb(mask, va, flags); +} + static const struct hypervisor_ops __initdata ops = { .name = "Hyper-V", .setup = setup, .ap_setup = ap_setup, .e820_fixup = e820_fixup, + .flush_tlb = flush_tlb, }; /* diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h index eb14ea43e5..78e52f74ce 100644 --- a/xen/arch/x86/guest/hyperv/private.h +++ b/xen/arch/x86/guest/hyperv/private.h @@ -22,10 +22,14 @@ #ifndef __XEN_HYPERV_PRIVIATE_H__ #define __XEN_HYPERV_PRIVIATE_H__ +#include #include DECLARE_PER_CPU(void *, hv_input_page); DECLARE_PER_CPU(void *, hv_vp_assist); DECLARE_PER_CPU(uint32_t, hv_vp_index); +int hyperv_flush_tlb(const cpumask_t *mask, const void *va, + unsigned int flags); + #endif /* __XEN_HYPERV_PRIVIATE_H__ */ diff --git a/xen/arch/x86/guest/hyperv/tlb.c b/xen/arch/x86/guest/hyperv/tlb.c new file mode 100644 index 0000000000..48f527229e --- /dev/null +++ b/xen/arch/x86/guest/hyperv/tlb.c @@ -0,0 +1,41 @@ +/****************************************************************************** + * arch/x86/guest/hyperv/tlb.c + * + * Support for TLB management using hypercalls + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + * + * Copyright (c) 2020 Microsoft. + */ + +#include +#include + +#include "private.h" + +int hyperv_flush_tlb(const cpumask_t *mask, const void *va, + unsigned int flags) +{ + return -EOPNOTSUPP; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From patchwork Wed Feb 12 16:09:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 11378701 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 00A811805 for ; Wed, 12 Feb 2020 16:11:00 +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 C685D2082F for ; Wed, 12 Feb 2020 16:10:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JFPn51+G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C685D2082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=xen.org 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 1j1ua9-0003Rr-8o; Wed, 12 Feb 2020 16:09:45 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j1ua7-0003RC-DT for xen-devel@lists.xenproject.org; Wed, 12 Feb 2020 16:09:43 +0000 X-Inumbo-ID: 0bd48cac-4db2-11ea-ade5-bc764e2007e4 Received: from mail-wm1-x342.google.com (unknown [2a00:1450:4864:20::342]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 0bd48cac-4db2-11ea-ade5-bc764e2007e4; Wed, 12 Feb 2020 16:09:29 +0000 (UTC) Received: by mail-wm1-x342.google.com with SMTP id t14so3153163wmi.5 for ; Wed, 12 Feb 2020 08:09:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ydWvk0smCY6uoEuwo9BlmC3I8ThSoNpZz7RCbSXh68Q=; b=JFPn51+G9Ql7ZSdKBwjRobPeLBIIoUlx1M6QqIK92YAVdMkfF0CVUMKwruBM246W64 P/k8G3bJDUCPS3vA01fjJTH3SgJ47FpXSIQrvdinzME9nMKVTDBHs9iv24ul4DCR0qwG OwV3A9iZ7nAKpwlnKejpIx85IfpGLFw1Wxb/vG+KhcM0ra86ED1cC5lVa7NDTw598xf9 wZOtYgw2W5NbhD26RQ1RRc2yCn2z1R2vchGFi4PrGP0fGR9a18vUv404LDSdt+hZj4Vt cTf+w4A0HpFK8jruv5enKUXEgwoe8a05euowC293ZamsWb63Yturn6tm5JZDph7/oPm8 NrNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ydWvk0smCY6uoEuwo9BlmC3I8ThSoNpZz7RCbSXh68Q=; b=IspWhbIa4Lr12IMV6Cgl3ORlkzLGTHmDO2R/vXgYGtgHc1LWqzuWdsJaQom3/SdJrD XzP2caweA32ArZndDD4pvnMke1PTOu2XeHPdYsePgXfTBqxdbbQW+a53b1r1UT800AgM f7RBbKmEGB9nVrk6GFQveldLbBhjbtcHQ26wvVyEpgTWsoNAJCL7thHV0IJz19l+LJ2K 7TXl9rWD7pE+C8RqbZPk8vWc1IM/6iFgBG17AJ0hNbsrHwkG7vA12VdIITn909+Nth8u MzSbKy2glcPTjptD7zPFVTuUkWDMxRFwVuAgIkHaQLQ893WrIGSZqGixQ2SU9Cin9ohj ttow== X-Gm-Message-State: APjAAAXrKSdzSZVJYGG8Ie9YmW4hPYg7TE2BGHeN7LWRSJNxcGxmuFMF Y57ywrG3ywRGxUTxU70NwdL6ws3L X-Google-Smtp-Source: APXvYqyzPBMXXPPLOqroBObFLj+zi2m4AJKiCOqpU4xeMM3zfmLKmc19nqOCXDdGEoe0Jtm2jViIOw== X-Received: by 2002:a1c:1f56:: with SMTP id f83mr13346342wmf.93.1581523766878; Wed, 12 Feb 2020 08:09:26 -0800 (PST) Received: from localhost.localdomain (41.142.6.51.dyn.plus.net. [51.6.142.41]) by smtp.gmail.com with ESMTPSA id o4sm1142500wrx.25.2020.02.12.08.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Feb 2020 08:09:26 -0800 (PST) From: Wei Liu X-Google-Original-From: Wei Liu To: Xen Development List Date: Wed, 12 Feb 2020 16:09:18 +0000 Message-Id: <20200212160918.18470-5-liuwe@microsoft.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200212160918.18470-1-liuwe@microsoft.com> References: <20200212160918.18470-1-liuwe@microsoft.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/4] x86/hyperv: L0 assisted TLB flush X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , Wei Liu , Andrew Cooper , Paul Durrant , Michael Kelley , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Implement L0 assisted TLB flush for Xen on Hyper-V. It takes advantage of several hypercalls: * HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST * HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX * HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE * HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX Pick the most efficient hypercalls available. Signed-off-by: Wei Liu --- xen/arch/x86/guest/hyperv/Makefile | 1 + xen/arch/x86/guest/hyperv/private.h | 9 ++ xen/arch/x86/guest/hyperv/tlb.c | 172 +++++++++++++++++++++++++++- xen/arch/x86/guest/hyperv/util.c | 72 ++++++++++++ 4 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 xen/arch/x86/guest/hyperv/util.c diff --git a/xen/arch/x86/guest/hyperv/Makefile b/xen/arch/x86/guest/hyperv/Makefile index 18902c33e9..0e39410968 100644 --- a/xen/arch/x86/guest/hyperv/Makefile +++ b/xen/arch/x86/guest/hyperv/Makefile @@ -1,2 +1,3 @@ obj-y += hyperv.o obj-y += tlb.o +obj-y += util.o diff --git a/xen/arch/x86/guest/hyperv/private.h b/xen/arch/x86/guest/hyperv/private.h index 78e52f74ce..311f060495 100644 --- a/xen/arch/x86/guest/hyperv/private.h +++ b/xen/arch/x86/guest/hyperv/private.h @@ -24,12 +24,21 @@ #include #include +#include DECLARE_PER_CPU(void *, hv_input_page); DECLARE_PER_CPU(void *, hv_vp_assist); DECLARE_PER_CPU(uint32_t, hv_vp_index); +static inline uint32_t hv_vp_index(int cpu) +{ + return per_cpu(hv_vp_index, cpu); +} + int hyperv_flush_tlb(const cpumask_t *mask, const void *va, unsigned int flags); +/* Returns number of banks, -ev if error */ +int cpumask_to_vpset(struct hv_vpset *vpset, const cpumask_t *mask); + #endif /* __XEN_HYPERV_PRIVIATE_H__ */ diff --git a/xen/arch/x86/guest/hyperv/tlb.c b/xen/arch/x86/guest/hyperv/tlb.c index 48f527229e..99b789d9e9 100644 --- a/xen/arch/x86/guest/hyperv/tlb.c +++ b/xen/arch/x86/guest/hyperv/tlb.c @@ -19,15 +19,185 @@ * Copyright (c) 2020 Microsoft. */ +#include #include #include +#include +#include +#include + #include "private.h" +/* + * It is possible to encode up to 4096 pages using the lower 12 bits + * in an element of gva_list + */ +#define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE) +#define ORDER_TO_BYTES(order) ((1ul << (order)) * PAGE_SIZE) + +static unsigned int fill_gva_list(uint64_t *gva_list, const void *va, + unsigned int order) +{ + unsigned long start = (unsigned long)va; + unsigned long end = start + ORDER_TO_BYTES(order) - 1; + unsigned int n = 0; + + do { + unsigned long remain = end > start ? end - start : 0; + + gva_list[n] = start & PAGE_MASK; + + /* + * Use lower 12 bits to encode the number of additional pages + * to flush + */ + if ( remain >= HV_TLB_FLUSH_UNIT ) + { + gva_list[n] |= ~PAGE_MASK; + start += HV_TLB_FLUSH_UNIT; + } + else if ( remain ) + { + gva_list[n] |= (remain - 1) >> PAGE_SHIFT; + start = end; + } + + n++; + } while ( start < end ); + + return n; +} + +static uint64_t flush_tlb_ex(const cpumask_t *mask, const void *va, + unsigned int flags) +{ + struct hv_tlb_flush_ex *flush = this_cpu(hv_input_page); + int nr_banks; + unsigned int max_gvas; + unsigned int order = flags & FLUSH_ORDER_MASK; + uint64_t ret; + + ASSERT(flush); + ASSERT(!local_irq_is_enabled()); + + if ( !(ms_hyperv.hints & HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED) ) + return ~0ULL; + + flush->address_space = 0; + flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES; + if ( !(flags & FLUSH_TLB_GLOBAL) ) + flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY; + + flush->hv_vp_set.valid_bank_mask = 0; + flush->hv_vp_set.format = HV_GENERIC_SET_SPARSE_4K; + + nr_banks = cpumask_to_vpset(&flush->hv_vp_set, mask); + if ( nr_banks < 0 ) + return ~0ULL; + + max_gvas = + (PAGE_SIZE - sizeof(*flush) - nr_banks * + sizeof(flush->hv_vp_set.bank_contents[0])) / + sizeof(uint64_t); /* gva is represented as uint64_t */ + + /* + * Flush the entire address space if va is NULL or if there is not + * enough space for gva_list. + */ + if ( !va || (ORDER_TO_BYTES(order) / HV_TLB_FLUSH_UNIT) > max_gvas ) + ret = hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX, 0, + nr_banks, virt_to_maddr(flush), 0); + else + { + uint64_t *gva_list = (uint64_t *)flush + sizeof(*flush) + nr_banks; + unsigned int gvas = fill_gva_list(gva_list, va, order); + + ret = hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX, + gvas, nr_banks, virt_to_maddr(flush), 0); + } + + return ret; +} + int hyperv_flush_tlb(const cpumask_t *mask, const void *va, unsigned int flags) { - return -EOPNOTSUPP; + unsigned long irq_flags; + struct hv_tlb_flush *flush = this_cpu(hv_input_page); + uint64_t ret; + unsigned int order = flags & FLUSH_ORDER_MASK; + unsigned int max_gvas; + + ASSERT(flush); + ASSERT(!cpumask_empty(mask)); + + local_irq_save(irq_flags); + + flush->address_space = 0; + flush->flags = HV_FLUSH_ALL_VIRTUAL_ADDRESS_SPACES; + flush->processor_mask = 0; + if ( !(flags & FLUSH_TLB_GLOBAL) ) + flush->flags |= HV_FLUSH_NON_GLOBAL_MAPPINGS_ONLY; + + if ( cpumask_equal(mask, &cpu_online_map) ) + flush->flags |= HV_FLUSH_ALL_PROCESSORS; + else + { + int cpu; + + /* + * Normally VP indices are in ascending order and match Xen's + * idea of CPU ids. Check the last index to see if VP index is + * >= 64. If so, we can skip setting up parameters for + * non-applicable hypercalls without looking further. + */ + if ( hv_vp_index(cpumask_last(mask)) >= 64 ) + goto do_ex_hypercall; + + for_each_cpu ( cpu, mask ) + { + uint32_t vpid = hv_vp_index(cpu); + + if ( vpid > ms_hyperv.max_vp_index ) + { + local_irq_restore(irq_flags); + return -ENXIO; + } + + if ( vpid >= 64 ) + goto do_ex_hypercall; + + __set_bit(vpid, &flush->processor_mask); + } + } + + max_gvas = (PAGE_SIZE - sizeof(*flush)) / sizeof(flush->gva_list[0]); + + /* + * Flush the entire address space if va is NULL or if there is not + * enough space for gva_list. + */ + if ( !va || (ORDER_TO_BYTES(order) / HV_TLB_FLUSH_UNIT) > max_gvas ) + ret = hv_do_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE, + virt_to_maddr(flush), 0); + else + { + unsigned int gvas = fill_gva_list(flush->gva_list, va, order); + + ret = hv_do_rep_hypercall(HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST, gvas, 0, + virt_to_maddr(flush), 0); + } + + goto done; + + do_ex_hypercall: + ret = flush_tlb_ex(mask, va, flags); + + done: + local_irq_restore(irq_flags); + + return ret & HV_HYPERCALL_RESULT_MASK; } /* diff --git a/xen/arch/x86/guest/hyperv/util.c b/xen/arch/x86/guest/hyperv/util.c new file mode 100644 index 0000000000..9d0b5f4a46 --- /dev/null +++ b/xen/arch/x86/guest/hyperv/util.c @@ -0,0 +1,72 @@ +/****************************************************************************** + * arch/x86/guest/hyperv/util.c + * + * Hyper-V utility functions + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + * + * Copyright (c) 2020 Microsoft. + */ + +#include +#include +#include + +#include +#include + +#include "private.h" + +int cpumask_to_vpset(struct hv_vpset *vpset, + const cpumask_t *mask) +{ + int nr = 1, cpu, vcpu_bank, vcpu_offset; + int max_banks = ms_hyperv.max_vp_index / 64; + + /* Up to 64 banks can be represented by valid_bank_mask */ + if ( max_banks >= 64 ) + return -1; + + /* Clear all banks to avoid flushing unwanted CPUs */ + for ( vcpu_bank = 0; vcpu_bank <= max_banks; vcpu_bank++ ) + vpset->bank_contents[vcpu_bank] = 0; + + vpset->valid_bank_mask = 0; + + for_each_cpu ( cpu, mask ) + { + int vcpu = hv_vp_index(cpu); + + vcpu_bank = vcpu / 64; + vcpu_offset = vcpu % 64; + + __set_bit(vcpu_offset, &vpset->bank_contents[vcpu_bank]); + __set_bit(vcpu_bank, &vpset->valid_bank_mask); + + if ( vcpu_bank >= nr ) + nr = vcpu_bank + 1; + } + + return nr; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */