From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47AD2C4320A for ; Fri, 23 Jul 2021 19:16:36 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 A5CA660E9C for ; Fri, 23 Jul 2021 19:16:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A5CA660E9C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:49796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m70ew-0008No-F1 for qemu-devel@archiver.kernel.org; Fri, 23 Jul 2021 15:16:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m70eL-0007dX-BE for qemu-devel@nongnu.org; Fri, 23 Jul 2021 15:15:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21192) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m70eG-0006Vx-Sx for qemu-devel@nongnu.org; Fri, 23 Jul 2021 15:15:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627067749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=I5589nGDaWbQaH0o1zhXcop9hLxZKdbnVZ3SdcfrDRA=; b=i5Y7hFs05QbUJRZghUP8WWe3/K+kkZaEOMMNHiKMSLFRomzBBkP7YSnS/+9YMlDFSLABiP 9HWJTLZE/Wi2jRzg0uw8Ts6YOZjkucUaQFK9jSuQFnTE2lRzN9mfKumFj6kXNyTGGXfJUB 4dI+lmU+t0qyMsOT/6jxCjenjme8OnU= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-2olBwYeUO7K1OBihfvR30g-1; Fri, 23 Jul 2021 15:15:46 -0400 X-MC-Unique: 2olBwYeUO7K1OBihfvR30g-1 Received: by mail-wm1-f70.google.com with SMTP id n7-20020a05600c3b87b029024e59a633baso725684wms.5 for ; Fri, 23 Jul 2021 12:15:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=I5589nGDaWbQaH0o1zhXcop9hLxZKdbnVZ3SdcfrDRA=; b=c7i/Gc/xAWopvPBHMf7ZThPH/obhHyHirICL0ib+XwjKWUp2yAEFglACE98oMTJaR1 0xiqiFiIJPF+BiUXK16ktrAKRMe1wsJ02NxZOSnHVBzFrm5zVqqeziIZEUyhmQj1OnOd KjzVNFJ8PhrK1UAC8LYIFRw9whU5kZ9T2+LMLI4jDOkQnp1ZVUwQcRoRCi5W9ooAK5jo xltTx860emhvVZxVGIHkoq6dxNBVHjLP8BTTbgtWhTExGY1GI4h4I6GQykiSLpdKeER9 aW8Wk2T5hQQsP2oK4sZmA7Cj66ao00e49kN52nHRxHMJqDRpoV2kZDCeO1dS9XwJIMnT 6Xhg== X-Gm-Message-State: AOAM530mihHylwnAleeuNReslJf9RhRz28zostGQZA8dYPRiRgS199Ov GgWjZzjtWzSrTsAUcmXegwGdimOpJj8n4bhLKUovpJz9sc1t/Gmwu3X5N2UkF3y+2I6W/q+r+hp uJ3/uCNt6bT1xTYY= X-Received: by 2002:adf:fac7:: with SMTP id a7mr6730690wrs.384.1627067744916; Fri, 23 Jul 2021 12:15:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhMuuCO6QS8ZSFt3jE2Y7e/OmTaKlrR5vu77yXCfBeh9uPZCW0Tji1rZi7M/FplQlYZe0mxg== X-Received: by 2002:adf:fac7:: with SMTP id a7mr6730664wrs.384.1627067744723; Fri, 23 Jul 2021 12:15:44 -0700 (PDT) Received: from [192.168.3.132] (p5b0c676e.dip0.t-ipconnect.de. [91.12.103.110]) by smtp.gmail.com with ESMTPSA id y19sm5865104wma.21.2021.07.23.12.15.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jul 2021 12:15:44 -0700 (PDT) To: Peter Xu References: <20210720130304.26323-1-david@redhat.com> <20210720130304.26323-2-david@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH resend v2 1/5] tpm: mark correct memory region range dirty when clearing RAM Message-ID: Date: Fri, 23 Jul 2021 21:15:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=216.205.24.124; envelope-from=david@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -44 X-Spam_score: -4.5 X-Spam_bar: ---- X-Spam_report: (-4.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.472, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.203, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Eduardo Habkost , "Michael S. Tsirkin" , Stefan Berger , qemu-devel@nongnu.org, "Dr . David Alan Gilbert" , Alex Williamson , Claudio Fontana , Paolo Bonzini , =?UTF-8?Q?Marc-Andr=c3=a9_Lureau?= , =?UTF-8?Q?Alex_Benn=c3=a9e?= , Igor Mammedov , Stefan Berger Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 23.07.21 16:52, Peter Xu wrote: > On Tue, Jul 20, 2021 at 03:03:00PM +0200, David Hildenbrand wrote: >> @@ -30,11 +30,13 @@ void tpm_ppi_reset(TPMPPI *tpmppi) >> guest_phys_blocks_init(&guest_phys_blocks); >> guest_phys_blocks_append(&guest_phys_blocks); >> QTAILQ_FOREACH(block, &guest_phys_blocks.head, next) { >> + ram_addr_t mr_start = memory_region_get_ram_addr(block->mr); >> + >> trace_tpm_ppi_memset(block->host_addr, >> block->target_end - block->target_start); >> memset(block->host_addr, 0, >> block->target_end - block->target_start); >> - memory_region_set_dirty(block->mr, 0, >> + memory_region_set_dirty(block->mr, block->target_start - mr_start, >> block->target_end - block->target_start); > > target_start should falls in gpa range, while mr_start is ram_addr_t. I am not > sure whether this is right.. When I wrote that code I was under the impression that memory_region_get_ram_addr() would give the GPA where the memory region starts, but ... that's not correct as you point out. "offset" confusion :) > > Neither do I know how to get correct mr offset with the existing info we've got > from GuestPhysBlock. Maybe we need to teach guest_phys_blocks_region_add() to > also record section->offset_within_region? We might actually want offset_within_address_space + offset_within_region, so we can calculate the GPA difference to see where inside the ramblock we end up. I'll have a look next week, thanks for noticing! -- Thanks, David / dhildenb