From owner-svn-src-stable-10@freebsd.org Wed Jan 4 05:36:39 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 70A4CC9ED1D; Wed, 4 Jan 2017 05:36:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4B4F31B9E; Wed, 4 Jan 2017 05:36:39 +0000 (UTC) (envelope-from sephe@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v045acvp009672; Wed, 4 Jan 2017 05:36:38 GMT (envelope-from sephe@FreeBSD.org) Received: (from sephe@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v045acT2009670; Wed, 4 Jan 2017 05:36:38 GMT (envelope-from sephe@FreeBSD.org) Message-Id: <201701040536.v045acT2009670@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sephe set sender to sephe@FreeBSD.org using -f From: Sepherosa Ziehau Date: Wed, 4 Jan 2017 05:36:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r311256 - stable/10/sys/dev/hyperv/utilities X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2017 05:36:39 -0000 Author: sephe Date: Wed Jan 4 05:36:38 2017 New Revision: 311256 URL: https://svnweb.freebsd.org/changeset/base/311256 Log: MFC 310462,310465 310462 hyperv/ic: Fix version4 timesync message format. It is not compat w/ the old timesync message format, which the message type stays the same as the old timesync message. Sponsored by: Microsoft 310465 hyperv/ic: Allow applying the samples from hypervisor unconditionally. Sponsored by: Microsoft Modified: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Wed Jan 4 05:32:29 2017 (r311255) +++ stable/10/sys/dev/hyperv/utilities/vmbus_icreg.h Wed Jan 4 05:36:38 2017 (r311256) @@ -114,8 +114,17 @@ struct vmbus_icmsg_timesync { struct vmbus_icmsg_hdr ic_hdr; uint64_t ic_hvtime; uint64_t ic_vmtime; + uint64_t ic_rtt; + uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ +} __packed; + +/* VMBUS_ICMSG_TYPE_TIMESYNC, MSGVER4 */ +struct vmbus_icmsg_timesync4 { + struct vmbus_icmsg_hdr ic_hdr; + uint64_t ic_hvtime; uint64_t ic_sent_tc; uint8_t ic_tsflags; /* VMBUS_ICMSG_TS_FLAG_ */ + uint8_t ic_rsvd[5]; } __packed; #define VMBUS_ICMSG_TS_FLAG_SYNC 0x01 Modified: stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c ============================================================================== --- stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c Wed Jan 4 05:32:29 2017 (r311255) +++ stable/10/sys/dev/hyperv/utilities/vmbus_timesync.c Wed Jan 4 05:36:38 2017 (r311256) @@ -48,8 +48,11 @@ __FBSDID("$FreeBSD$"); #define VMBUS_TIMESYNC_MSGVER \ VMBUS_IC_VERSION(VMBUS_TIMESYNC_MSGVER_MAJOR, 0) +#define VMBUS_TIMESYNC_MSGVER4(sc) \ + VMBUS_ICVER_LE(VMBUS_IC_VERSION(4, 0), (sc)->ic_msgver) + #define VMBUS_TIMESYNC_DORTT(sc) \ - ((sc)->ic_msgver >= VMBUS_IC_VERSION(4, 0) && \ + (VMBUS_TIMESYNC_MSGVER4((sc)) &&\ (hyperv_features & CPUID_HV_MSR_TIME_REFCNT)) static int vmbus_timesync_probe(device_t); @@ -136,7 +139,7 @@ vmbus_timesync(struct vmbus_ic_softc *sc } if ((tsflags & VMBUS_ICMSG_TS_FLAG_SAMPLE) && - vmbus_ts_sample_thresh > 0) { + vmbus_ts_sample_thresh >= 0) { int64_t diff; if (vmbus_ts_sample_verbose) { @@ -174,7 +177,6 @@ vmbus_timesync_cb(struct vmbus_channel * { struct vmbus_ic_softc *sc = xsc; struct vmbus_icmsg_hdr *hdr; - const struct vmbus_icmsg_timesync *msg; int dlen, error; uint64_t xactid; void *data; @@ -209,14 +211,28 @@ vmbus_timesync_cb(struct vmbus_channel * break; case VMBUS_ICMSG_TYPE_TIMESYNC: - if (dlen < sizeof(*msg)) { - device_printf(sc->ic_dev, "invalid timesync len %d\n", - dlen); - return; + if (VMBUS_TIMESYNC_MSGVER4(sc)) { + const struct vmbus_icmsg_timesync4 *msg4; + + if (dlen < sizeof(*msg4)) { + device_printf(sc->ic_dev, "invalid timesync4 " + "len %d\n", dlen); + return; + } + msg4 = data; + vmbus_timesync(sc, msg4->ic_hvtime, msg4->ic_sent_tc, + msg4->ic_tsflags); + } else { + const struct vmbus_icmsg_timesync *msg; + + if (dlen < sizeof(*msg)) { + device_printf(sc->ic_dev, "invalid timesync " + "len %d\n", dlen); + return; + } + msg = data; + vmbus_timesync(sc, msg->ic_hvtime, 0, msg->ic_tsflags); } - msg = data; - vmbus_timesync(sc, msg->ic_hvtime, msg->ic_sent_tc, - msg->ic_tsflags); break; default: