From owner-freebsd-virtualization@freebsd.org Fri Jul 31 16:54:55 2020 Return-Path: Delivered-To: freebsd-virtualization@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BB41B37D2BE for ; Fri, 31 Jul 2020 16:54:55 +0000 (UTC) (envelope-from chuck@tuffli.net) Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BJD0b08n6z3SQ5 for ; Fri, 31 Jul 2020 16:54:54 +0000 (UTC) (envelope-from chuck@tuffli.net) Received: by mail-ej1-x632.google.com with SMTP id o23so4615631ejr.1 for ; Fri, 31 Jul 2020 09:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tuffli-net.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=YI/jCWQKTCZVIiRn0Z79rbZ5G6GVQLmBXkFQ3HoRiCU=; b=BuhkbbF+C4/AATTCmACJWhA+TaMJzYO7Y/IQa3ORczTpMDBhkeakwVyq99UM9oE1LX UYFsUYrX3i+UsfcHHwaTTQx4hksERTkIIoOPBfOL3NIBaaYwisUJEgOwEYChhzcmO9M6 Hd1qpc68Femez8fYNWzSpqzt1gkTElI/7eenPxpo2/Fl6c1Eai2B+cMY45aSIBIjvmW/ 83N9jPbfB9PnOELhvSuSu4vrJTCfe78yFA2/9okrYgLe1yEF7tKwHYnLzACo6bP5kZOQ x6ft8nJ+KgD///zWfJoT5xbhDjyif4SqvA3q55GNZCJy+UL65bFn2pQ4YKLuXoQRtz85 Fa/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YI/jCWQKTCZVIiRn0Z79rbZ5G6GVQLmBXkFQ3HoRiCU=; b=bWRJvvGVMVE1DPpGVwXvyD/nr+Fom0WazNqMHEMjpIO0m8iTRn1RQ3aRK6yw2F3C4U qS7Q0nWhJX64epDp6/wdpuwCSc0JKevWkXSJPWqVcCZxbwOYLmauq3U2pAfeT8Kw9fTJ x8GDG7xcNq0rbp3EVZ3emK3E6afhkbCQRVwO5aE0/mkbwJGI4bFIGsmK26SiGOK0SVzu IczK4AadhVrNnFGpi69k10h6mdduWnnySp0/vAZfOjHVCN6LXMNXu9grEQd+CNdR4QqS Nk819dZ0j86rWWIyH+r01gQymUjwQ7Min9bqrkBHtL6+Ti5DjQZGopA/iqPPjdfhZv+C rLIA== X-Gm-Message-State: AOAM530DcekWE8BGUEmB7XKgQ10k5amlCfVkIl4clDzaTKOMX0w9Z2Jm NGUFD+oXHowQAoQoWkpDUAGfavAnB/m9sKgTew+C8w== X-Google-Smtp-Source: ABdhPJx4e3jw/UMtjCafie6mmSN+ReKKcM6QEM5iAV8ZrxuuyNVOa0PI9dixygEjac2IPgV9oIPF/k0CuuH4dJjCRuk= X-Received: by 2002:a17:906:b6d0:: with SMTP id ec16mr4929232ejb.94.1596214493494; Fri, 31 Jul 2020 09:54:53 -0700 (PDT) MIME-Version: 1.0 From: Chuck Tuffli Date: Fri, 31 Jul 2020 09:54:42 -0700 Message-ID: Subject: bhyve guest illegal instruction To: John Baldwin , grehan@freebsd.org, freebsd-virtualization@freebsd.org X-Rspamd-Queue-Id: 4BJD0b08n6z3SQ5 X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=tuffli-net.20150623.gappssmtp.com header.s=20150623 header.b=BuhkbbF+; dmarc=none; spf=permerror (mx1.freebsd.org: domain of chuck@tuffli.net uses mechanism not recognized by this client) smtp.mailfrom=chuck@tuffli.net X-Spamd-Result: default: False [-3.40 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.98)[-0.985]; R_DKIM_ALLOW(-0.20)[tuffli-net.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-0.98)[-0.980]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-virtualization@freebsd.org]; DMARC_NA(0.00)[tuffli.net]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_SPF_PERMFAIL(0.00)[empty SPF record]; DKIM_TRACE(0.00)[tuffli-net.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::632:from]; NEURAL_HAM_SHORT(-1.13)[-1.131]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-virtualization@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "Discussion of various virtualization techniques FreeBSD supports." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Jul 2020 16:54:55 -0000 (apologies for the resend, this time with a Subject) John / Peter I'm running an application in a Linux guest under bhyve that is core dumping because of an Illegal instruction. Running a simplified case in gdb shows: $ gdb -q rdtscp Reading symbols from rdtscp...done. (gdb) run Starting program: /home/tuffli/rdtscp Program received signal SIGILL, Illegal instruction. main (argc=1, argv=0x7fffffffeae8) at rdtscp.c:12 12 time1 = __builtin_ia32_rdtscp(&dummy); (gdb) l 7 main(int argc, char *argv[]) 8 { 9 uint64_t time1, time2; 10 uint32_t dummy; 11 12 time1 = __builtin_ia32_rdtscp(&dummy); 13 usleep(1000); 14 time2 = __builtin_ia32_rdtscp(&dummy); 15 16 printf("time delta %lu\n", time2 - time1); 17 18 return (EXIT_SUCCESS); 19 } This same program works on the FreeBSD 12-stable machine hosting the VM as well as another bare-metal Linux host. Poking around in the vmm code, I found /* * Hide rdtscp/ia32_tsc_aux until we know how * to deal with them. */ regs[3] &= ~AMDID_RDTSCP; break; in sys/amd64/vmm/x86.c which I _think_ is relevant because lscpu doesn't show the rdtscp flag. If this is the root cause, what would need to be done to implement this? --chuck