From patchwork Thu Nov 4 12:54:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tim Gardner X-Patchwork-Id: 1550909 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=KtiraMjJ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HlNtc6WKPz9sP7 for ; Thu, 4 Nov 2021 23:56:24 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1micHr-0005TU-VP; Thu, 04 Nov 2021 12:56:12 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1micH9-0004Y1-Lz for kernel-team@lists.ubuntu.com; Thu, 04 Nov 2021 12:55:27 +0000 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 2F1183F1F5 for ; Thu, 4 Nov 2021 12:55:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1636030526; bh=u5tPSHYEsf6IAWQb4Y/3qfoeTEjjvRSgsm6oqme/z1w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KtiraMjJKtxzSn7Jb/rFucMoQUh0QdtpQzckNx0uYjKnt2p8i48WFjpNdy9oy0jJF awkJ4+b2wPUw4sAnqSYxB64gFJVJPE6aheNO2nXxtWFdX4FLVynLhYiooTO7/WOX61 8emkLp+cglBCrXERS+R/gDuM38JwnQJSgs6SzrMVde9y0KQxbYKDA0ruM6e65T3Q0c FjYz7b40Lo/oNPunX4TvynmmQI0nohLFQFxHOS8YeBl08S3Qm5ZfLJqfoHl3ejRxIb 2icloN0e/aJyP7aW0ZwWMbOhjh+9R7FJBU97s1MXXb5HkBRsentNZkDNlhfySoBz7a i+9I1801KAjVQ== Received: by mail-pl1-f198.google.com with SMTP id q2-20020a170902dac200b001422673d86fso2251340plx.20 for ; Thu, 04 Nov 2021 05:55:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=u5tPSHYEsf6IAWQb4Y/3qfoeTEjjvRSgsm6oqme/z1w=; b=YWzc/+dgQj25+Z7Yxkiw7lZWl+vbAgn6a9gdb11EXM7X0+vlD8+ef2XnOZw1TBPimQ a/7vr8GZiWSG9MXCCQwTGcZy/ZMOXsrDdMvVJVUj3kXGUDXYpM4C3Y4iS6WUXIQFM9Dz Mf5ugT9M/9S/Be1yZZuc83UNSs75gE/5whwClnoMd6YJJIskYVzFLrEUVbpZEwkzNT03 bY/+HZyXogC14WiIZQSnPzFPlyINQBazCdf1rCjPZFI8rGDkgclTM4us867QSvbKB6sK 8ux+8wwyL6ZvpdFuD/dWZe0gc5uvPgV49aGV5pTFrsmIGWTDEWTSOKa8VZ2WmNgiqqf7 rDLA== X-Gm-Message-State: AOAM530IpVdf6kmAz60i5LxYPzDyGvgWs0W1Mf2Xm/tp+StRBZ0BWlbq rqWUXtY1zIIzMzV4QtZulaEYxJurSg7flp+TPql2Y848yg1Ue24UmsyMu0oUMml6F5xxMuU34Vc nbtStjZL+PDTTy/7e/LPnKBT7WDdmHFA9+lLLHDdftw== X-Received: by 2002:a17:903:1207:b0:138:e2f9:6c98 with SMTP id l7-20020a170903120700b00138e2f96c98mr46044931plh.11.1636030524393; Thu, 04 Nov 2021 05:55:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyis9YCDY6shdUyjmMLN2xjzRqaXQiq7FCUdwkF4l0cq8uDHo+7Yg8L+r8CJQzE4B0juyxeDA== X-Received: by 2002:a17:903:1207:b0:138:e2f9:6c98 with SMTP id l7-20020a170903120700b00138e2f96c98mr46044903plh.11.1636030524089; Thu, 04 Nov 2021 05:55:24 -0700 (PDT) Received: from localhost.localdomain ([69.163.84.166]) by smtp.gmail.com with ESMTPSA id y4sm5283859pfi.178.2021.11.04.05.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Nov 2021 05:55:23 -0700 (PDT) From: Tim Gardner To: kernel-team@lists.ubuntu.com Subject: [PATCH 16/41] x86/hyperv: Move hv_do_rep_hypercall to asm-generic Date: Thu, 4 Nov 2021 06:54:24 -0600 Message-Id: <20211104125449.16540-17-tim.gardner@canonical.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211104125449.16540-1-tim.gardner@canonical.com> References: <20211104125449.16540-1-tim.gardner@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Joseph Salisbury BugLink: https://bugs.launchpad.net/bugs/1949770 This patch makes no functional changes. It simply moves hv_do_rep_hypercall() out of arch/x86/include/asm/mshyperv.h and into asm-generic/mshyperv.h hv_do_rep_hypercall() is architecture independent, so it makes sense that it should be in the architecture independent mshyperv.h, not in the x86-specific mshyperv.h. This is done in preperation for a follow up patch which creates a consistent pattern for checking Hyper-V hypercall status. Signed-off-by: Joseph Salisbury Reviewed-by: Michael Kelley Link: https://lore.kernel.org/r/1618620183-9967-1-git-send-email-joseph.salisbury@linux.microsoft.com Signed-off-by: Wei Liu (cherry picked from commit 6523592cee4650c6aa997d69cd0045a01e07a1ef) Signed-off-by: Marcelo Henrique Cerri --- arch/x86/include/asm/mshyperv.h | 32 -------------------------------- include/asm-generic/mshyperv.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index 4548d2deb5b8..7c3ff0d38e04 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -140,38 +140,6 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2) return hv_status; } -/* - * Rep hypercalls. Callers of this functions are supposed to ensure that - * rep_count and varhead_size comply with Hyper-V hypercall definition. - */ -static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size, - void *input, void *output) -{ - u64 control = code; - u64 status; - u16 rep_comp; - - control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET; - control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; - - do { - status = hv_do_hypercall(control, input, output); - if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS) - return status; - - /* Bits 32-43 of status have 'Reps completed' data. */ - rep_comp = (status & HV_HYPERCALL_REP_COMP_MASK) >> - HV_HYPERCALL_REP_COMP_OFFSET; - - control &= ~HV_HYPERCALL_REP_START_MASK; - control |= (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET; - - touch_nmi_watchdog(); - } while (rep_comp < rep_count); - - return status; -} - extern struct hv_vp_assist_page **hv_vp_assist_page; static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu) diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h index ffc7fcf0dd8b..7821d8180efe 100644 --- a/include/asm-generic/mshyperv.h +++ b/include/asm-generic/mshyperv.h @@ -39,6 +39,37 @@ extern struct ms_hyperv_info ms_hyperv; extern u64 hv_do_hypercall(u64 control, void *inputaddr, void *outputaddr); extern u64 hv_do_fast_hypercall8(u16 control, u64 input8); +/* + * Rep hypercalls. Callers of this functions are supposed to ensure that + * rep_count and varhead_size comply with Hyper-V hypercall definition. + */ +static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size, + void *input, void *output) +{ + u64 control = code; + u64 status; + u16 rep_comp; + + control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET; + control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; + + do { + status = hv_do_hypercall(control, input, output); + if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS) + return status; + + /* Bits 32-43 of status have 'Reps completed' data. */ + rep_comp = (status & HV_HYPERCALL_REP_COMP_MASK) >> + HV_HYPERCALL_REP_COMP_OFFSET; + + control &= ~HV_HYPERCALL_REP_START_MASK; + control |= (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET; + + touch_nmi_watchdog(); + } while (rep_comp < rep_count); + + return status; +} /* Generate the guest OS identifier as described in the Hyper-V TLFS */ static inline __u64 generate_guest_id(__u64 d_info1, __u64 kernel_version,