Browse Source

[build] Keep gcc 4.4 happy

gcc 4.4 adds another few warnings, and also seems to complain if we
place %ebp in the clobber list for any inline asm.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
54fbd11221
5 changed files with 49 additions and 30 deletions
  1. 8
    6
      src/arch/i386/firmware/pcbios/memmap.c
  2. 4
    2
      src/arch/i386/image/multiboot.c
  3. 18
    2
      src/include/gpxe/tls.h
  4. 1
    1
      src/net/ipv4.c
  5. 18
    19
      src/net/tls.c

+ 8
- 6
src/arch/i386/firmware/pcbios/memmap.c View File

158
 	uint32_t smap;
158
 	uint32_t smap;
159
 	size_t size;
159
 	size_t size;
160
 	unsigned int flags;
160
 	unsigned int flags;
161
-	unsigned int discard_d, discard_D;
161
+	unsigned int discard_D;
162
 
162
 
163
 	/* Clear the E820 buffer.  Do this once before starting,
163
 	/* Clear the E820 buffer.  Do this once before starting,
164
 	 * rather than on each call; some BIOSes rely on the contents
164
 	 * rather than on each call; some BIOSes rely on the contents
171
 		 * this by telling gcc that all non-output registers
171
 		 * this by telling gcc that all non-output registers
172
 		 * may be corrupted.
172
 		 * may be corrupted.
173
 		 */
173
 		 */
174
-		__asm__ __volatile__ ( REAL_CODE ( "stc\n\t"
174
+		__asm__ __volatile__ ( REAL_CODE ( "pushl %%ebp\n\t"
175
+						   "stc\n\t"
175
 						   "int $0x15\n\t"
176
 						   "int $0x15\n\t"
176
 						   "pushfw\n\t"
177
 						   "pushfw\n\t"
177
-						   "popw %w0\n\t" )
178
-				       : "=r" ( flags ), "=a" ( smap ),
179
-					 "=b" ( next ), "=D" ( discard_D ),
180
-					 "=c" ( size ), "=d" ( discard_d )
178
+						   "popw %%dx\n\t"
179
+						   "popl %%ebp\n\t" )
180
+				       : "=a" ( smap ), "=b" ( next ),
181
+					 "=c" ( size ), "=d" ( flags ),
182
+					 "=D" ( discard_D )
181
 				       : "a" ( 0xe820 ), "b" ( next ),
183
 				       : "a" ( 0xe820 ), "b" ( next ),
182
 					 "D" ( __from_data16 ( &e820buf ) ),
184
 					 "D" ( __from_data16 ( &e820buf ) ),
183
 					 "c" ( sizeof ( e820buf ) ),
185
 					 "c" ( sizeof ( e820buf ) ),

+ 4
- 2
src/arch/i386/image/multiboot.c View File

282
 	/* Jump to OS with flat physical addressing */
282
 	/* Jump to OS with flat physical addressing */
283
 	DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
283
 	DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
284
 	       image, entry );
284
 	       image, entry );
285
-	__asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" )
285
+	__asm__ __volatile__ ( PHYS_CODE ( "pushl %%ebp\n\t"
286
+					   "call *%%edi\n\t"
287
+					   "popl %%ebp\n\t" )
286
 			       : : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
288
 			       : : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
287
 			           "b" ( virt_to_phys ( &mbinfo ) ),
289
 			           "b" ( virt_to_phys ( &mbinfo ) ),
288
 			           "D" ( entry )
290
 			           "D" ( entry )
289
-			       : "ecx", "edx", "esi", "ebp", "memory" );
291
+			       : "ecx", "edx", "esi", "memory" );
290
 
292
 
291
 	DBGC ( image, "MULTIBOOT %p returned\n", image );
293
 	DBGC ( image, "MULTIBOOT %p returned\n", image );
292
 
294
 

+ 18
- 2
src/include/gpxe/tls.h View File

109
 	void *mac_secret;
109
 	void *mac_secret;
110
 };
110
 };
111
 
111
 
112
+/** TLS pre-master secret */
113
+struct tls_pre_master_secret {
114
+	/** TLS version */
115
+	uint16_t version;
116
+	/** Random data */
117
+	uint8_t random[46];
118
+} __attribute__ (( packed ));
119
+
120
+/** TLS client random data */
121
+struct tls_client_random {
122
+	/** GMT Unix time */
123
+	uint32_t gmt_unix_time;
124
+	/** Random data */
125
+	uint8_t random[28];
126
+} __attribute__ (( packed ));
127
+
112
 /** A TLS session */
128
 /** A TLS session */
113
 struct tls_session {
129
 struct tls_session {
114
 	/** Reference counter */
130
 	/** Reference counter */
128
 	/** Next RX cipher specification */
144
 	/** Next RX cipher specification */
129
 	struct tls_cipherspec rx_cipherspec_pending;
145
 	struct tls_cipherspec rx_cipherspec_pending;
130
 	/** Premaster secret */
146
 	/** Premaster secret */
131
-	uint8_t pre_master_secret[48];
147
+	struct tls_pre_master_secret pre_master_secret;
132
 	/** Master secret */
148
 	/** Master secret */
133
 	uint8_t master_secret[48];
149
 	uint8_t master_secret[48];
134
 	/** Server random bytes */
150
 	/** Server random bytes */
135
 	uint8_t server_random[32];
151
 	uint8_t server_random[32];
136
 	/** Client random bytes */
152
 	/** Client random bytes */
137
-	uint8_t client_random[32];
153
+	struct tls_client_random client_random;
138
 	/** MD5 context for handshake verification */
154
 	/** MD5 context for handshake verification */
139
 	uint8_t handshake_md5_ctx[MD5_CTX_SIZE];
155
 	uint8_t handshake_md5_ctx[MD5_CTX_SIZE];
140
 	/** SHA1 context for handshake verification */
156
 	/** SHA1 context for handshake verification */

+ 1
- 1
src/net/ipv4.c View File

188
 				free_iob ( iobuf );
188
 				free_iob ( iobuf );
189
 
189
 
190
 				/** Check if the fragment series is over */
190
 				/** Check if the fragment series is over */
191
-				if ( !iphdr->frags & IP_MASK_MOREFRAGS ) {
191
+				if ( ! ( iphdr->frags & IP_MASK_MOREFRAGS ) ) {
192
 					iobuf = fragbuf->frag_iob;
192
 					iobuf = fragbuf->frag_iob;
193
 					free_fragbuf ( fragbuf );
193
 					free_fragbuf ( fragbuf );
194
 					return iobuf;
194
 					return iobuf;

+ 18
- 19
src/net/tls.c View File

270
 	DBGC_HD ( tls, &tls->pre_master_secret,
270
 	DBGC_HD ( tls, &tls->pre_master_secret,
271
 		  sizeof ( tls->pre_master_secret ) );
271
 		  sizeof ( tls->pre_master_secret ) );
272
 	DBGC ( tls, "TLS %p client random bytes:\n", tls );
272
 	DBGC ( tls, "TLS %p client random bytes:\n", tls );
273
-	DBGC_HD ( tls, &tls->client_random, sizeof ( tls->server_random ) );
273
+	DBGC_HD ( tls, &tls->client_random, sizeof ( tls->client_random ) );
274
 	DBGC ( tls, "TLS %p server random bytes:\n", tls );
274
 	DBGC ( tls, "TLS %p server random bytes:\n", tls );
275
 	DBGC_HD ( tls, &tls->server_random, sizeof ( tls->server_random ) );
275
 	DBGC_HD ( tls, &tls->server_random, sizeof ( tls->server_random ) );
276
 
276
 
277
-	tls_prf_label ( tls, tls->pre_master_secret,
277
+	tls_prf_label ( tls, &tls->pre_master_secret,
278
 			sizeof ( tls->pre_master_secret ),
278
 			sizeof ( tls->pre_master_secret ),
279
-			tls->master_secret, sizeof ( tls->master_secret ),
279
+			&tls->master_secret, sizeof ( tls->master_secret ),
280
 			"master secret",
280
 			"master secret",
281
-			tls->client_random, sizeof ( tls->client_random ),
282
-			tls->server_random, sizeof ( tls->server_random ) );
281
+			&tls->client_random, sizeof ( tls->client_random ),
282
+			&tls->server_random, sizeof ( tls->server_random ) );
283
 
283
 
284
 	DBGC ( tls, "TLS %p generated master secret:\n", tls );
284
 	DBGC ( tls, "TLS %p generated master secret:\n", tls );
285
 	DBGC_HD ( tls, &tls->master_secret, sizeof ( tls->master_secret ) );
285
 	DBGC_HD ( tls, &tls->master_secret, sizeof ( tls->master_secret ) );
304
 	int rc;
304
 	int rc;
305
 
305
 
306
 	/* Generate key block */
306
 	/* Generate key block */
307
-	tls_prf_label ( tls, tls->master_secret, sizeof ( tls->master_secret ),
307
+	tls_prf_label ( tls, &tls->master_secret, sizeof ( tls->master_secret ),
308
 			key_block, sizeof ( key_block ), "key expansion",
308
 			key_block, sizeof ( key_block ), "key expansion",
309
-			tls->server_random, sizeof ( tls->server_random ),
310
-			tls->client_random, sizeof ( tls->client_random ) );
309
+			&tls->server_random, sizeof ( tls->server_random ),
310
+			&tls->client_random, sizeof ( tls->client_random ) );
311
 
311
 
312
 	/* Split key block into portions */
312
 	/* Split key block into portions */
313
 	key = key_block;
313
 	key = key_block;
604
 			      htonl ( sizeof ( hello ) -
604
 			      htonl ( sizeof ( hello ) -
605
 				      sizeof ( hello.type_length ) ) );
605
 				      sizeof ( hello.type_length ) ) );
606
 	hello.version = htons ( TLS_VERSION_TLS_1_0 );
606
 	hello.version = htons ( TLS_VERSION_TLS_1_0 );
607
-	memcpy ( &hello.random, tls->client_random, sizeof ( hello.random ) );
607
+	memcpy ( &hello.random, &tls->client_random, sizeof ( hello.random ) );
608
 	hello.cipher_suite_len = htons ( sizeof ( hello.cipher_suites ) );
608
 	hello.cipher_suite_len = htons ( sizeof ( hello.cipher_suites ) );
609
 	hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
609
 	hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
610
 	hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
610
 	hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
643
 		  sizeof ( tls->pre_master_secret ) );
643
 		  sizeof ( tls->pre_master_secret ) );
644
 	DBGC_HD ( tls, tls->rsa_mod, tls->rsa_mod_len );
644
 	DBGC_HD ( tls, tls->rsa_mod, tls->rsa_mod_len );
645
 	DBGC_HD ( tls, tls->rsa_pub_exp, tls->rsa_pub_exp_len );
645
 	DBGC_HD ( tls, tls->rsa_pub_exp, tls->rsa_pub_exp_len );
646
-	RSA_encrypt ( rsa_ctx, tls->pre_master_secret,
646
+	RSA_encrypt ( rsa_ctx, ( const uint8_t * ) &tls->pre_master_secret,
647
 		      sizeof ( tls->pre_master_secret ),
647
 		      sizeof ( tls->pre_master_secret ),
648
 		      key_xchg.encrypted_pre_master_secret, 0 );
648
 		      key_xchg.encrypted_pre_master_secret, 0 );
649
 	DBGC ( tls, "RSA encrypt done.  Ciphertext:\n" );
649
 	DBGC ( tls, "RSA encrypt done.  Ciphertext:\n" );
685
 				 htonl ( sizeof ( finished ) -
685
 				 htonl ( sizeof ( finished ) -
686
 					 sizeof ( finished.type_length ) ) );
686
 					 sizeof ( finished.type_length ) ) );
687
 	tls_verify_handshake ( tls, digest );
687
 	tls_verify_handshake ( tls, digest );
688
-	tls_prf_label ( tls, tls->master_secret, sizeof ( tls->master_secret ),
688
+	tls_prf_label ( tls, &tls->master_secret, sizeof ( tls->master_secret ),
689
 			finished.verify_data, sizeof ( finished.verify_data ),
689
 			finished.verify_data, sizeof ( finished.verify_data ),
690
 			"client finished", digest, sizeof ( digest ) );
690
 			"client finished", digest, sizeof ( digest ) );
691
 
691
 
802
 	}
802
 	}
803
 
803
 
804
 	/* Copy out server random bytes */
804
 	/* Copy out server random bytes */
805
-	memcpy ( tls->server_random, hello_a->random,
805
+	memcpy ( &tls->server_random, &hello_a->random,
806
 		 sizeof ( tls->server_random ) );
806
 		 sizeof ( tls->server_random ) );
807
 
807
 
808
 	/* Select cipher suite */
808
 	/* Select cipher suite */
1710
 	tls_clear_cipher ( tls, &tls->tx_cipherspec_pending );
1710
 	tls_clear_cipher ( tls, &tls->tx_cipherspec_pending );
1711
 	tls_clear_cipher ( tls, &tls->rx_cipherspec );
1711
 	tls_clear_cipher ( tls, &tls->rx_cipherspec );
1712
 	tls_clear_cipher ( tls, &tls->rx_cipherspec_pending );
1712
 	tls_clear_cipher ( tls, &tls->rx_cipherspec_pending );
1713
-	*( ( uint32_t * ) tls->client_random ) = 0; /* GMT Unix time */
1714
-	tls_generate_random ( ( tls->client_random + 4 ),
1715
-			      ( sizeof ( tls->client_random ) - 4 ) );
1716
-	*( ( uint16_t * ) tls->pre_master_secret )
1717
-		= htons ( TLS_VERSION_TLS_1_0 );
1718
-	tls_generate_random ( ( tls->pre_master_secret + 2 ),
1719
-			      ( sizeof ( tls->pre_master_secret ) - 2 ) );
1713
+	tls->client_random.gmt_unix_time = 0;
1714
+	tls_generate_random ( &tls->client_random.random,
1715
+			      ( sizeof ( tls->client_random.random ) ) );
1716
+	tls->pre_master_secret.version = htons ( TLS_VERSION_TLS_1_0 );
1717
+	tls_generate_random ( &tls->pre_master_secret.random,
1718
+			      ( sizeof ( tls->pre_master_secret.random ) ) );
1720
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1719
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1721
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1720
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1722
 	tls->tx_state = TLS_TX_CLIENT_HELLO;
1721
 	tls->tx_state = TLS_TX_CLIENT_HELLO;

Loading…
Cancel
Save