From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from userp2130.oracle.com ([156.151.31.86]) by Galois.linutronix.de with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1fCygC-00072V-10 for speck@linutronix.de; Mon, 30 Apr 2018 04:36:41 +0200 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w3U2V4lV157575 for ; Mon, 30 Apr 2018 02:36:33 GMT Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2hmgdjac63-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 30 Apr 2018 02:36:33 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w3U2aWjW005120 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 30 Apr 2018 02:36:33 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w3U2aWPC018630 for ; Mon, 30 Apr 2018 02:36:32 GMT Date: Sun, 29 Apr 2018 22:36:27 -0400 From: Konrad Rzeszutek Wilk Subject: [MODERATED] Re: [patch V7 13/15] SBB 13 Message-ID: <20180430023627.GD30984@char.us.oracle.com> References: <20180429193045.711908246@linutronix.de> <20180429193938.557096663@linutronix.de> MIME-Version: 1.0 In-Reply-To: <20180429193938.557096663@linutronix.de> Content-Type: multipart/mixed; boundary="cQXOx3fnlpmgJsTP" Content-Disposition: inline To: speck@linutronix.de List-ID: --cQXOx3fnlpmgJsTP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > PR_SET_SPECULATION_CTRL has these additional return values: > > -ERANGE: arg3 is incorrect, i.e. it's not either PR_SPEC_ENABLE or PR_SPEC_DISABLE s/not either/neither/ ? Feel free to ignore it of course but it read more obvious to me that way. And also attaching the testing program I spoke off. My previous testing (which I alluded to in previous emails) missed the obvious case of 'r < 0' meaning 0xfffffff.. which would report that all bits are set (duh). --cQXOx3fnlpmgJsTP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="test-prctl.c" #include #include #define SPEC_CTRL_RDS_SHIFT 2 /* Reduced Data Speculation bit */ /* Per task speculation control */ #define PR_SET_SPECULATION_CTRL 52 #define PR_GET_SPECULATION_CTRL 53 /* Speculation control variants */ # define PR_SPEC_STORE_BYPASS 0 /* Return and control values for PR_SET/GET_SPECULATION_CTRL */ # define PR_SPEC_NOT_AFFECTED 0 # define PR_SPEC_PRCTL (1UL << 0) # define PR_SPEC_ENABLE (1UL << 1) # define PR_SPEC_DISABLE (1UL << 2) void print_bitfields(int r) { if ( r >= 0 ) fprintf(stderr, " r=%s %s %s\n", r & PR_SPEC_PRCTL ? "PR_SPEC_PRCTL" : "", r & PR_SPEC_ENABLE ? "PR_SPEC_ENABLE" : "", r & PR_SPEC_DISABLE ? "PR_SPEC_DISABLE" : ""); } void get_v(void) { int r; r = prctl(PR_GET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS); fprintf(stderr, " PR_GET_SPECULATION_CTRL PR_SPEC_STORE_BYPASS r=%d\n", r); print_bitfields(r); } int main(void) { int r; fprintf(stderr,"Initial state\n"); get_v(); r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); /* Two DISALBE in a row*/ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); /* Two enable in a row. */ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_ENABLE); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_ENABLE r=%d\n", r); print_bitfields(r); get_v(); r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_ENABLE); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_ENABLE r=%d\n", r); print_bitfields(r); get_v(); fprintf(stderr,"\nReal test-case\n"); /* The real normal test-case */ r = prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE); fprintf(stderr, "PR_SET_SPECULATION_CTRL PR_SPEC_DISABLE r=%d\n", r); print_bitfields(r); get_v(); do { } while (1); return 0; } --cQXOx3fnlpmgJsTP--