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 15 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,7 +158,7 @@ static int meme820 ( struct memory_map *memmap ) {
158 158
 	uint32_t smap;
159 159
 	size_t size;
160 160
 	unsigned int flags;
161
-	unsigned int discard_d, discard_D;
161
+	unsigned int discard_D;
162 162
 
163 163
 	/* Clear the E820 buffer.  Do this once before starting,
164 164
 	 * rather than on each call; some BIOSes rely on the contents
@@ -171,13 +171,15 @@ static int meme820 ( struct memory_map *memmap ) {
171 171
 		 * this by telling gcc that all non-output registers
172 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 176
 						   "int $0x15\n\t"
176 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 183
 				       : "a" ( 0xe820 ), "b" ( next ),
182 184
 					 "D" ( __from_data16 ( &e820buf ) ),
183 185
 					 "c" ( sizeof ( e820buf ) ),

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

@@ -282,11 +282,13 @@ static int multiboot_exec ( struct image *image ) {
282 282
 	/* Jump to OS with flat physical addressing */
283 283
 	DBGC ( image, "MULTIBOOT %p starting execution at %lx\n",
284 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 288
 			       : : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ),
287 289
 			           "b" ( virt_to_phys ( &mbinfo ) ),
288 290
 			           "D" ( entry )
289
-			       : "ecx", "edx", "esi", "ebp", "memory" );
291
+			       : "ecx", "edx", "esi", "memory" );
290 292
 
291 293
 	DBGC ( image, "MULTIBOOT %p returned\n", image );
292 294
 

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

@@ -109,6 +109,22 @@ struct tls_cipherspec {
109 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 128
 /** A TLS session */
113 129
 struct tls_session {
114 130
 	/** Reference counter */
@@ -128,13 +144,13 @@ struct tls_session {
128 144
 	/** Next RX cipher specification */
129 145
 	struct tls_cipherspec rx_cipherspec_pending;
130 146
 	/** Premaster secret */
131
-	uint8_t pre_master_secret[48];
147
+	struct tls_pre_master_secret pre_master_secret;
132 148
 	/** Master secret */
133 149
 	uint8_t master_secret[48];
134 150
 	/** Server random bytes */
135 151
 	uint8_t server_random[32];
136 152
 	/** Client random bytes */
137
-	uint8_t client_random[32];
153
+	struct tls_client_random client_random;
138 154
 	/** MD5 context for handshake verification */
139 155
 	uint8_t handshake_md5_ctx[MD5_CTX_SIZE];
140 156
 	/** SHA1 context for handshake verification */

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

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

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

@@ -270,16 +270,16 @@ static void tls_generate_master_secret ( struct tls_session *tls ) {
270 270
 	DBGC_HD ( tls, &tls->pre_master_secret,
271 271
 		  sizeof ( tls->pre_master_secret ) );
272 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 274
 	DBGC ( tls, "TLS %p server random bytes:\n", tls );
275 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 278
 			sizeof ( tls->pre_master_secret ),
279
-			tls->master_secret, sizeof ( tls->master_secret ),
279
+			&tls->master_secret, sizeof ( tls->master_secret ),
280 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 284
 	DBGC ( tls, "TLS %p generated master secret:\n", tls );
285 285
 	DBGC_HD ( tls, &tls->master_secret, sizeof ( tls->master_secret ) );
@@ -304,10 +304,10 @@ static int tls_generate_keys ( struct tls_session *tls ) {
304 304
 	int rc;
305 305
 
306 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 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 312
 	/* Split key block into portions */
313 313
 	key = key_block;
@@ -604,7 +604,7 @@ static int tls_send_client_hello ( struct tls_session *tls ) {
604 604
 			      htonl ( sizeof ( hello ) -
605 605
 				      sizeof ( hello.type_length ) ) );
606 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 608
 	hello.cipher_suite_len = htons ( sizeof ( hello.cipher_suites ) );
609 609
 	hello.cipher_suites[0] = htons ( TLS_RSA_WITH_AES_128_CBC_SHA );
610 610
 	hello.cipher_suites[1] = htons ( TLS_RSA_WITH_AES_256_CBC_SHA );
@@ -643,7 +643,7 @@ static int tls_send_client_key_exchange ( struct tls_session *tls ) {
643 643
 		  sizeof ( tls->pre_master_secret ) );
644 644
 	DBGC_HD ( tls, tls->rsa_mod, tls->rsa_mod_len );
645 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 647
 		      sizeof ( tls->pre_master_secret ),
648 648
 		      key_xchg.encrypted_pre_master_secret, 0 );
649 649
 	DBGC ( tls, "RSA encrypt done.  Ciphertext:\n" );
@@ -685,7 +685,7 @@ static int tls_send_finished ( struct tls_session *tls ) {
685 685
 				 htonl ( sizeof ( finished ) -
686 686
 					 sizeof ( finished.type_length ) ) );
687 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 689
 			finished.verify_data, sizeof ( finished.verify_data ),
690 690
 			"client finished", digest, sizeof ( digest ) );
691 691
 
@@ -802,7 +802,7 @@ static int tls_new_server_hello ( struct tls_session *tls,
802 802
 	}
803 803
 
804 804
 	/* Copy out server random bytes */
805
-	memcpy ( tls->server_random, hello_a->random,
805
+	memcpy ( &tls->server_random, &hello_a->random,
806 806
 		 sizeof ( tls->server_random ) );
807 807
 
808 808
 	/* Select cipher suite */
@@ -1710,13 +1710,12 @@ int add_tls ( struct xfer_interface *xfer, struct xfer_interface **next ) {
1710 1710
 	tls_clear_cipher ( tls, &tls->tx_cipherspec_pending );
1711 1711
 	tls_clear_cipher ( tls, &tls->rx_cipherspec );
1712 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 1719
 	digest_init ( &md5_algorithm, tls->handshake_md5_ctx );
1721 1720
 	digest_init ( &sha1_algorithm, tls->handshake_sha1_ctx );
1722 1721
 	tls->tx_state = TLS_TX_CLIENT_HELLO;

Loading…
Cancel
Save