Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp766487ybl; Fri, 30 Aug 2019 06:56:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwR1NDDUwb6I5kmuI7VgClJH1ujL6WkFPUT1w6vTkGhQWlhEbojTiIen4tuKlY8IZPPT+Io X-Received: by 2002:aa7:908b:: with SMTP id i11mr16130664pfa.199.1567173375473; Fri, 30 Aug 2019 06:56:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567173375; cv=none; d=google.com; s=arc-20160816; b=f6JOaHxOAeAYeJrx4YrCuZOr7gSXwvo9stODnYueUF90bwgTg+v584jcoirRGW8qBT gQrpsCm4mRLxDwmAb4g8wv2J1CYwE7sEOyfwB5K/oqp9p6VPjObRJ8oIFNjiCHD/v4qO PTKFgle3x++eyPIhJpKIrJhOM7ahk3mt6aMW4VVHVVA++dyp5y/cMu4/IvYEED9YxaNo JT5B4XNcc1U4sB4BZjS29amJ1BACk18LcRQAL4xBoDYUFTO9LtUUM+GSglCh1r+mlQAN /ZSzRJglGjpr5lqsxspNM0jeYkJRiFwlMGljNAkKNRE53iIcrHJnwLWyK7aubghlvQU6 jRFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uwyr09OeKTgN7mrxVHx+2hnXAPzOPQfRzUlZ2zECK50=; b=fKcGqv7qbnjypGP6o98Y7FP0nc8VbfnLU67K/0/FFcMBdhjdO/ZiUG5laO3MOyWdi+ qxbMoeJIwUDGxaXxP03Hl4xQVQ+CCjvEU5Lm3VyeVPTndJqCrGoe3yGm9RMKNZAL1u9l 5I8SQ3a/LXXMfh7TR+eECij2simm5H6RvmQMq2ntN8QQdLE7yqFbNXzPP8iCE274CRBL PgpL41BH8W0663Bqf7FmEFTkkNOSujEIEcZfyxx23HeJuDjNFznLbzg3QYxPRh6KF5Ak QZ868vbdZHmr36HuUv2jI+sOqEkdsEM2JeHeSkLOiQVz49OOevn89XiVbRErTY31E0gQ DRhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LJQhakBK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a4si3950973pfb.10.2019.08.30.06.55.59; Fri, 30 Aug 2019 06:56:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LJQhakBK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727904AbfH3NzM (ORCPT + 99 others); Fri, 30 Aug 2019 09:55:12 -0400 Received: from mail-yw1-f68.google.com ([209.85.161.68]:45492 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727780AbfH3NzM (ORCPT ); Fri, 30 Aug 2019 09:55:12 -0400 Received: by mail-yw1-f68.google.com with SMTP id n69so2385107ywd.12; Fri, 30 Aug 2019 06:55:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uwyr09OeKTgN7mrxVHx+2hnXAPzOPQfRzUlZ2zECK50=; b=LJQhakBK31minFRW4+8ZqTjPS3meQLKD9H4oU3dh9tMkpMp6sFAIeTMemX1uaJjgjR MXHO7nRFXUstF0WXKc7ByqGTy3QTteAYN8cOXjf7CG40/7dj59OjmKjymJ5Ty/GcqdA1 3luwpNCClgEG5EYsRPc8ECjrSyQWMb+h0QOS37SXa66utV+Oq0IpUDXV9IteyCXnImOR +EM49X/KYXCkxRBd9CoCUp6iaY3eNN54YtTQ1jx+prWFPdyWyl4quO0DvBUKe816r7El epndZ4XYWWHJWIPcEjR6uuNEed3xh8ZL8inhpE0WVZS1YHTy6UWTdlC6rCsLXSPL8eHy ofng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uwyr09OeKTgN7mrxVHx+2hnXAPzOPQfRzUlZ2zECK50=; b=EUc1/Cw3O0e1K5GB1HgcF/jMvE1ywRWpC1i+C/Hd/q1yTmP3eGQbHyV19oD4OrHv52 APD7HW7xaRGamtmvnGL2bg+FLT/SqWyyVCdDLd1ENheUxY5cRAYRHqqNplfBci0Ml05a jDilSANqRHlpcNkUHcDXezfsoGPKONab+XywBIETDSl9gRteHauJNRqY719lh4dgMNUt CdnmuW4dImdY5mO39NZJ5G+nXUeoE1ckUEosbnSm5ZTDNzWEeI9N9FCoEwfpwzfEIP4l WvFT/qtwlDHRrC5cF3iX4NY6EaLNbMCmi+iRcc+S1ZcaWJnjgv1dYXC1nIoOtUPP/sRX Jg+Q== X-Gm-Message-State: APjAAAXIjdDW2sLnvZCshXRng/K7+grBh0hxocja16m1/xVI7xtYL9Yk 0xL4kd6wQKNcHNzQVECwhcvKKZEzzlQGVwHmB6M= X-Received: by 2002:a81:9108:: with SMTP id i8mr11138441ywg.346.1567173311094; Fri, 30 Aug 2019 06:55:11 -0700 (PDT) MIME-Version: 1.0 References: <20190830095639.4562-1-kkamagui@gmail.com> <20190830095639.4562-3-kkamagui@gmail.com> <20190830124334.GA10004@ziepe.ca> In-Reply-To: <20190830124334.GA10004@ziepe.ca> From: Seunghun Han Date: Fri, 30 Aug 2019 22:54:59 +0900 Message-ID: Subject: Re: [PATCH 2/2] tpm: tpm_crb: enhance resource mapping mechanism for supporting AMD's fTPM To: Jason Gunthorpe Cc: Jarkko Sakkinen , Peter Huewe , "open list:TPM DEVICE DRIVER" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > On Fri, Aug 30, 2019 at 06:56:39PM +0900, Seunghun Han wrote: > > I got an AMD system which had a Ryzen Threadripper 1950X and MSI > > mainboard, and I had a problem with AMD's fTPM. My machine showed an error > > message below, and the fTPM didn't work because of it. > > > > [ 5.732084] tpm_crb MSFT0101:00: can't request region for resource > > [mem 0x79b4f000-0x79b4ffff] > > [ 5.732089] tpm_crb: probe of MSFT0101:00 failed with error -16 > > > > When I saw the iomem, I found two fTPM regions were in the ACPI NVS area. > > The regions are below. > > > > 79a39000-79b6afff : ACPI Non-volatile Storage > > 79b4b000-79b4bfff : MSFT0101:00 > > 79b4f000-79b4ffff : MSFT0101:00 > > > > After analyzing this issue, I found that crb_map_io() function called > > devm_ioremap_resource() and it failed. The ACPI NVS didn't allow the TPM > > CRB driver to assign a resource in it because a busy bit was set to > > the ACPI NVS area. > > > > To support AMD's fTPM, I added a function to check intersects between > > the TPM region and ACPI NVS before it mapped the region. If some > > intersects are detected, the function just calls devm_ioremap() for > > a workaround. If there is no intersect, it calls devm_ioremap_resource(). > > > > Signed-off-by: Seunghun Han > > --- > > drivers/char/tpm/tpm_crb.c | 25 +++++++++++++++++++++++-- > > 1 file changed, 23 insertions(+), 2 deletions(-) > > This still seems to result in two drivers controlling the same > memory. Does this create bugs and races during resume? > > Jason When I tested this patch in my machine, it seemed that ACPI NVS was saved after TPM CRB driver sent "TPM2_Shutdown(STATE)" to the fTPM while suspending. Then, ACPI NVS was restored while resuming. After resuming, PCRs didn't change and TPM2 tools such as tpm2_pcrlist, tpm2_extend, tpm2_getrandoms worked well. So, according to my test result, it seems that the patch doesn't create bugs and race during resume. Seunghun