Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3476426pxb; Mon, 4 Apr 2022 18:11:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjtA5Wfl6e2XdeNtd9GrcPn+/yvnSRGqW9XIU4bcB1TeD9NXQ2WWcoU5n89OSjTo9EpiiU X-Received: by 2002:aa7:8d54:0:b0:4e0:bd6:cfb9 with SMTP id s20-20020aa78d54000000b004e00bd6cfb9mr1114897pfe.60.1649121114148; Mon, 04 Apr 2022 18:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649121114; cv=none; d=google.com; s=arc-20160816; b=Ds+hBnhaggOcKJAyKrAdqZShKKDX6shg8pedsCRuK7uONEqYOU64bQpWZ2PXWVbQ6A z/FI1DdV0ghq04yUErBqnNeMDRnEiq3c5sMU93/pE5A0YwI6hLiyVGUjbVs+RI1tyzMt nVWR94dD6JBZiAvvQencdfprIi1SBOUUNxbDraf2Q1eXnqkAd89tRUxzPw4IJHV9o7vj 2L4ZxB7d7fc9DVqeeY2b2HLckG1i2xZfCegYijmAykN8JuNE6HQsUr3AOCt00NgHVBAa 3DMO1FVV+IBHJeawNyiAQAvrjWE2UN0g/Mcu+hrzpCylG+DUW0SRGcQydvHWA4uC7d01 Ga+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9jHgBZFPUit49TSD+W0vcWqdUpO3LWDl0zvqR1OYTQU=; b=TUb6oTV5lj2QxTvn1ynEerDexLFPrIXkzegHS4xcUlzbta/sVbW4YzXBTplNHhW90D kCBcYbukGAx5KGBjGf0wIR0pYKMH9MEzEkB14huIDLmqQnLrIAME+2e7Co0rIj73xeiO atUxphGt7Jqr9lpVqOUbJZOh8bIyj0eSCOgtB0TMq5QjJ9mIy+HgqIqpKe2Gu7Rl/UwJ APqPLnUijUTgvb8QGKLav30ihwErkLIddyPr+PnhTxApAlIzukAskbVI+bN+OJgLvtSr TYaFKZTCNvyQcKneBnPMsChB4yJofblRjyVN9g92aYFTV8UuMB1Xv7Y6M9SKtsjkDWH4 P1aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BsOyCfH9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bj15-20020a056a02018f00b0039901c42ef8si8174171pgb.386.2022.04.04.18.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:11:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BsOyCfH9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5D8FD1753AF; Mon, 4 Apr 2022 17:11:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245271AbiDAQa1 (ORCPT + 99 others); Fri, 1 Apr 2022 12:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348714AbiDAQ2A (ORCPT ); Fri, 1 Apr 2022 12:28:00 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEE1B22513; Fri, 1 Apr 2022 09:00:46 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id yy13so6836121ejb.2; Fri, 01 Apr 2022 09:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9jHgBZFPUit49TSD+W0vcWqdUpO3LWDl0zvqR1OYTQU=; b=BsOyCfH9ORI2nZzbH2g35bwoxed+qvcrU4SidE+0rO+cW4Q2BiKEdUfs1IOK65bqQJ kmBeDHc1KB2uUHHtgRmqtotncTR3ZXPqkihXVwYZna8VX0gsPmFgakoNB1nAjXZq5W/4 pIf5ucClXaSqWIZUNRBZ7EEUm5ZwArgN4Cun0Z0lkiDUmxEWsOFIegHUCP0IKu/6fNDI wiypDEWT0b+cGAUjXeD/zbLlw5jnPl86pgSD4bcbF6x/8sakRcLTQQhTy2EGQiW3rTVV 0ky9PxC4fjOmxjMdLz1ytCREtWe2yJf5t7EJCP+WvJbwwdKDVUR9ssFocXMD3yaI4vAy PcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9jHgBZFPUit49TSD+W0vcWqdUpO3LWDl0zvqR1OYTQU=; b=KKzlvucaLBC8ZGXlEfJfCkLh3zio02Gwq3Ba46Cz1r81ZE/DnxCejBW9MH8HxnapOM zpUj4X+d24NBdHpewncrAqgJk0YW454bF/75PYRZQK615fq9AjJT5lD31H/+qklxysR6 H/klzghEJMoOr7M0BsbIrt8UxIz9mDEnNwSgk8soN3GRSlKkHo8THp0q7GtbbK2WJuyZ GWsri8a9xJzOyvpOg3NgT8rXTcoJnYYTKavgWhVteyBo91OOWwtEE0hl2BmIjgDV83Ir EkWCZkixPSKs4Yris9Gn/wM+2mfuFqQysedpPGK099xrc2quMqV9ySPLXGTz+bTBsCJ0 5l/A== X-Gm-Message-State: AOAM532rK9OontEJHvg/LKcIJBb3yP98G/AJ0MjY+nqEaTG9vJflSZQA QB4S4VoOF+hhcp97Ne+jn+Y= X-Received: by 2002:a17:907:7ea5:b0:6e1:13c3:e35f with SMTP id qb37-20020a1709077ea500b006e113c3e35fmr409386ejc.99.1648828845097; Fri, 01 Apr 2022 09:00:45 -0700 (PDT) Received: from anparri (host-82-59-4-232.retail.telecomitalia.it. [82.59.4.232]) by smtp.gmail.com with ESMTPSA id ds5-20020a170907724500b006df8f39dadesm1162174ejc.218.2022.04.01.09.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 09:00:44 -0700 (PDT) Date: Fri, 1 Apr 2022 18:00:36 +0200 From: Andrea Parri To: "Michael Kelley (LINUX)" Cc: KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , Dexuan Cui , Wei Hu , Lorenzo Pieralisi , Rob Herring , Krzysztof Wilczynski , Bjorn Helgaas , "linux-hyperv@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC PATCH 2/4] PCI: hv: Use vmbus_requestor to generate transaction IDs for VMbus hardening Message-ID: <20220401160036.GA437893@anparri> References: <20220328144244.100228-1-parri.andrea@gmail.com> <20220328144244.100228-3-parri.andrea@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 > > @@ -91,6 +91,9 @@ static enum pci_protocol_version_t pci_protocol_versions[] = { > > /* space for 32bit serial number as string */ > > #define SLOT_NAME_SIZE 11 > > > > +/* Size of requestor for VMbus */ > > +#define HV_PCI_RQSTOR_SIZE 64 > > Might include a comment about how this value was derived. I *think* > it is an arbitrary value based on the assumption that having more than > one request outstanding is rare, and so 64 should be extremely generous > in ensuring that we don't ever run out. Right, I've added a comment to that effect. > > @@ -2696,8 +2699,9 @@ static void hv_pci_onchannelcallback(void *context) > > const int packet_size = 0x100; > > int ret; > > struct hv_pcibus_device *hbus = context; > > + struct vmbus_channel *chan = hbus->hdev->channel; > > Having gotten the channel as a local variable, could also use the local as > the first argument to vmbus_recvpacket_raw(). Applied. > > @@ -2743,11 +2747,13 @@ static void hv_pci_onchannelcallback(void *context) > > switch (desc->type) { > > case VM_PKT_COMP: > > > > - /* > > - * The host is trusted, and thus it's safe to interpret > > - * this transaction ID as a pointer. > > - */ > > - comp_packet = (struct pci_packet *)req_id; > > + req_addr = chan->request_addr_callback(chan, req_id); > > + if (req_addr == VMBUS_RQST_ERROR) { > > + dev_warn_ratelimited(&hbus->hdev->device, > > + "Invalid request ID\n"); > > Could you include the req_id value in the error message that is output? I > was recently debugging a problem in the storvsc driver where having that > value would have been handy. Sure. Thanks, Andrea