Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp630273iob; Thu, 28 Apr 2022 08:56:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8hSPSBSshrOwJ3oSGq9ej468jU7MQ3ZcE/WDNA+M6qO9xEH/yoNht8JhTbUUbAs5/j6pZ X-Received: by 2002:a05:651c:2cd:b0:24f:1731:ee09 with SMTP id f13-20020a05651c02cd00b0024f1731ee09mr10928469ljo.253.1651161363316; Thu, 28 Apr 2022 08:56:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651161363; cv=none; d=google.com; s=arc-20160816; b=EXl1NxO2pPJN150KQdZO7Bvkpo5xQkE5qANnrlqLq0SkeDo1Kff314A2Bl246dM2TX hqekN1RIrfukHWty+KAwgIFqTvlp72PkLoICXnZTw6b5Zz4wJme4PnrA8NsxBnrW1rU9 aqfOKEvjEHLD/ASdHHdMy7f0P1y1sH5qESCyw88LvJPugrW9dN6rLfTtJYHIH4VQb0Ed aHRJItlblmOstCgNLp0GgFxSiwTmJMndDxWVpHKDtDexw2xRAr1oTGnNEy0qnXQGdIpH 6KCQg+uwalT5E7EtV2R/BWyyYSdX+iwbvf6oQR8TL/NlAgWQzIs57/Zts3wzoCSoraON z3/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=emDG9f3LFc4UN/7AhW/W0+ckar3Ug+oqa5fA2UJ5tjg=; b=PN4hijMNy5ugPPKLtwdDpGQazmPG/FJTkE+bPzQ9a6FrGwiGxa0ntpFsHWtBYvmhpS uuninLbvplkiPz1IhvDsx/2b3gBvoLGEataQqeNI4mWivgFip7pkZpAYGbpiNqYfiMzs pbh0v8DtCC25lBfToZP38SVGNrNmPe+Wo3AZR9umm5qXM0TwdgJUCnnxqsI76qM7XAA+ JvyZVl7j0yeWtdVHSSxqCiBRqxJUHR0H9bUcm3NAvuCKvr2HQqUmByccTb/v8/l24gUD 1SEacqHHez7oC6LdyGMKULBgY9kl/5OgDovq9j+bLiqM00NaiXPYU2ZJ68pjQrQgpa9Y Z2Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JndLe74S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a056512138400b0046d603c8470si6322970lfa.178.2022.04.28.08.55.34; Thu, 28 Apr 2022 08:56:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JndLe74S; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348602AbiD1OzE (ORCPT + 99 others); Thu, 28 Apr 2022 10:55:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbiD1Oyu (ORCPT ); Thu, 28 Apr 2022 10:54:50 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A9B85C844; Thu, 28 Apr 2022 07:51:35 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id r13so10083167ejd.5; Thu, 28 Apr 2022 07:51:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=emDG9f3LFc4UN/7AhW/W0+ckar3Ug+oqa5fA2UJ5tjg=; b=JndLe74SQfBVIJ2WpPhe5Wbx5xE7RqcorW45jPQ8Q3RK8izOuZ62/BUTNkGDR4Y0cM b9/D2ZWzWTr9AZVJnvuVlEc7hv0Anzjx0aYJNeBEsKU9DyLEBwQsudDz22hdve+EBNeS 9u3K3IBOvAsvYy5l5UEMQ4fzq5BZnaIUIv7vN8HX4fZIZqjAFHxgxDtb3FKLvo92HeLe pbpURa1z9zZbU8npF5Ni22aBAo0HCT6kBsfyg5tavA23gelCR0yWrcl2akRSmZv3BTkm cATdUwRQAibEt08Rq7JDIHnloAkK6wJ2jGKolJLbZhugt7KFeCilUCLAW7TfW8y5sdCy XdCQ== 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=emDG9f3LFc4UN/7AhW/W0+ckar3Ug+oqa5fA2UJ5tjg=; b=mDKWQekC3nGvOez4uSwq37aFQ08PYNqocCjQEuzDwQnTg+JShfg5RhpOUNipoCWDLm DAJULZsAzR/HKEnlgF1hYH+Mdfu8Ufm+iv1q6LdQanEdpo9kobPAXpqF6g/p7EWhXpmx 9EST2gXH7h3YQLzSqZ/u9h4Dy6NLC4JAKdPQQqbk925DvgieXDBoZZZi+n5W2neqZ8U4 PiFoZSafOYbJVrcoKdQGsZYJg2oiBAkdOdPesBmfOY1T37pnzeBT/PqEtVLel7kn3CEZ QOxPW0vWI3XG9CHCiRtIKwOguUZk6qeCXrNppdQPCQimDdqR3oZEj89UZduP3nBRZglo hmjQ== X-Gm-Message-State: AOAM53124AYlDIpn5kRxnhNT4qPecBzRWhnBlLN5Q0/KDTdO8e6OVZDf 8Ra2oSibr9Mf1p/PjxPTlU0= X-Received: by 2002:a17:907:9622:b0:6f3:9797:8eaf with SMTP id gb34-20020a170907962200b006f397978eafmr20337071ejc.96.1651157494095; Thu, 28 Apr 2022 07:51:34 -0700 (PDT) Received: from anparri.mshome.net (host-79-49-65-106.retail.telecomitalia.it. [79.49.65.106]) by smtp.gmail.com with ESMTPSA id x18-20020a170906b09200b006e8baac3a09sm61616ejy.157.2022.04.28.07.51.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 07:51:33 -0700 (PDT) From: "Andrea Parri (Microsoft)" To: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Michael Kelley , Stefano Garzarella , David Miller , Jakub Kicinski , Paolo Abeni Cc: linux-hyperv@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Andrea Parri (Microsoft)" Subject: [PATCH hyperv-next v2 4/5] Drivers: hv: vmbus: Accept hv_sock offers in isolated guests Date: Thu, 28 Apr 2022 16:51:06 +0200 Message-Id: <20220428145107.7878-5-parri.andrea@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220428145107.7878-1-parri.andrea@gmail.com> References: <20220428145107.7878-1-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org So that isolated guests can communicate with the host via hv_sock channels. Signed-off-by: Andrea Parri (Microsoft) Reviewed-by: Michael Kelley --- drivers/hv/channel_mgmt.c | 8 ++++++-- include/linux/hyperv.h | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c index 50fea31f019f6..0db1b775e0139 100644 --- a/drivers/hv/channel_mgmt.c +++ b/drivers/hv/channel_mgmt.c @@ -976,13 +976,17 @@ find_primary_channel_by_offer(const struct vmbus_channel_offer_channel *offer) return channel; } -static bool vmbus_is_valid_device(const guid_t *guid) +static bool vmbus_is_valid_offer(const struct vmbus_channel_offer_channel *offer) { + const guid_t *guid = &offer->offer.if_type; u16 i; if (!hv_is_isolation_supported()) return true; + if (is_hvsock_offer(offer)) + return true; + for (i = 0; i < ARRAY_SIZE(vmbus_devs); i++) { if (guid_equal(guid, &vmbus_devs[i].guid)) return vmbus_devs[i].allowed_in_isolated; @@ -1004,7 +1008,7 @@ static void vmbus_onoffer(struct vmbus_channel_message_header *hdr) trace_vmbus_onoffer(offer); - if (!vmbus_is_valid_device(&offer->offer.if_type)) { + if (!vmbus_is_valid_offer(offer)) { pr_err_ratelimited("Invalid offer %d from the host supporting isolation\n", offer->child_relid); atomic_dec(&vmbus_connection.offer_in_progress); diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index a01c9fd0a3348..b028905d8334e 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h @@ -1064,10 +1064,14 @@ u64 vmbus_request_addr_match(struct vmbus_channel *channel, u64 trans_id, u64 rqst_addr); u64 vmbus_request_addr(struct vmbus_channel *channel, u64 trans_id); +static inline bool is_hvsock_offer(const struct vmbus_channel_offer_channel *o) +{ + return !!(o->offer.chn_flags & VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); +} + static inline bool is_hvsock_channel(const struct vmbus_channel *c) { - return !!(c->offermsg.offer.chn_flags & - VMBUS_CHANNEL_TLNPI_PROVIDER_OFFER); + return is_hvsock_offer(&c->offermsg); } static inline bool is_sub_channel(const struct vmbus_channel *c) -- 2.25.1