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=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable 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 17016C4338F for ; Thu, 29 Jul 2021 13:53:38 +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 9BA5160EBC for ; Thu, 29 Jul 2021 13:53:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9BA5160EBC Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m96Tg-0005Hr-KB for qemu-devel@archiver.kernel.org; Thu, 29 Jul 2021 09:53:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m96Sp-0004Xz-3n for qemu-devel@nongnu.org; Thu, 29 Jul 2021 09:52:43 -0400 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]:17133) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m96Sl-0002BX-Nc for qemu-devel@nongnu.org; Thu, 29 Jul 2021 09:52:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1627566760; x=1659102760; h=from:to:cc:subject:date:message-id:mime-version; bh=vOwTZ5orfIykxaqp7JrAwtEKMxnNxzc6TJ11+WdRNEs=; b=IE328I3h5Vpdm0dvlEWilG/AEzBgXoT9wPVMe6B/CL7jczpsTBpFV4zP ozpcmoQFNP2QqLpHwSNoW063SGvW4Xz4fn/e+zrNiBKiem3CBwwAZxLlr K8i5IJEV1wwNzf7KIvXXNHEClUrrFQ+3amhg4X0QZhFg0v9j4hQ3Ny0Cv Q=; X-IronPort-AV: E=Sophos;i="5.84,278,1620691200"; d="scan'208";a="128792960" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-1e-c7c08562.us-east-1.amazon.com) ([10.43.8.2]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP; 29 Jul 2021 13:52:31 +0000 Received: from EX13D28EUC003.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1e-c7c08562.us-east-1.amazon.com (Postfix) with ESMTPS id C7CD4240413; Thu, 29 Jul 2021 13:52:29 +0000 (UTC) Received: from uc8bbc9586ea454.ant.amazon.com (10.43.160.66) by EX13D28EUC003.ant.amazon.com (10.43.164.43) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 29 Jul 2021 13:52:26 +0000 From: Siddharth Chandrasekaran To: Paolo Bonzini , Marcelo Tosatti CC: Siddharth Chandrasekaran , Liran Alon , Ioannis Aslanidis , , , Siddharth Chandrasekaran Subject: [PATCH] hyperv: Fix struct hv_message_header ordering Date: Thu, 29 Jul 2021 15:52:10 +0200 Message-ID: <20210729135210.16970-1-sidcha@amazon.de> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.66] X-ClientProxiedBy: EX13D20UWA003.ant.amazon.com (10.43.160.97) To EX13D28EUC003.ant.amazon.com (10.43.164.43) Precedence: Bulk Received-SPF: pass client-ip=52.95.49.90; envelope-from=prvs=8378b2bce=sidcha@amazon.de; helo=smtp-fw-6002.amazon.com X-Spam_score_int: -50 X-Spam_score: -5.1 X-Spam_bar: ----- X-Spam_report: (-5.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=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 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" According to Hyper-V TLFS Version 6.0b, struct hv_message_header members should be defined in the order: message_type, _reserved, message_flags, payload_size but we have it defined in the order: message_type, payload_size, message_flags, _reserved that is, the payload_size and _reserved members swapped. Due to this mix up, we were inadvertently causing two issues: - The payload_size field has invalid data; it didn't cause an issue so far because we are delivering only timer messages which has fixed size payloads the guest probably did a sizeof(payload) instead relying on the value of payload_size member. - The message_flags was always delivered as 0 to the guest; fortunately, according to section 13.3.1 message_flags is also treated as a reserved field. Although this is not causing an issue now, it might in future (we are adding more message types in our VSM implementation) so fix it to reflect the specification. Signed-off-by: Siddharth Chandrasekaran --- include/hw/hyperv/hyperv-proto.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/hw/hyperv/hyperv-proto.h b/include/hw/hyperv/hyperv-proto.h index 21dc28aee9..f578a60e78 100644 --- a/include/hw/hyperv/hyperv-proto.h +++ b/include/hw/hyperv/hyperv-proto.h @@ -101,9 +101,9 @@ struct hyperv_signal_event_input { */ struct hyperv_message_header { uint32_t message_type; - uint8_t payload_size; - uint8_t message_flags; /* HV_MESSAGE_FLAG_XX */ uint8_t _reserved[2]; + uint8_t message_flags; /* HV_MESSAGE_FLAG_XX */ + uint8_t payload_size; uint64_t sender; }; -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879